This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| input = "Johny johny yes pappa! Eating sugar?" | |
| regex = "(J|j)ohny" | |
| pattern = re.compile(regex) | |
| for item in pattern.finditer(input): | |
| print 'Match ', item.group(),' found at ',item.start() ,', ',item.end() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Java Regex sample | |
| String input = "Johny johny yes pappa! Eating sugar?"; | |
| String regex = "(J|j)ohny"; | |
| Pattern pattern = Pattern.compile(regex); // Compile the pattern | |
| Matcher matcher = pattern.matcher(input); // Generate the matcher for the input and pattern | |
| while(matcher.find()) { // Find match | |
| String matchedContent = matcher.group(); // get the matched content | |
| int start = matcher.start(); | |
| int end = matcher.end(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'Arunkumar Anand' | |
| def startAt(x): | |
| def incrementBy(y): | |
| return x + y | |
| return incrementBy | |
| closure1 = startAt(1) | |
| closure2 = startAt(5) |