Skip to content

Instantly share code, notes, and snippets.

@ariejan
Created January 6, 2009 22:38
Show Gist options
  • Save ariejan/44052 to your computer and use it in GitHub Desktop.
Save ariejan/44052 to your computer and use it in GitHub Desktop.
import java.util.regex.*;
class Regex2 {
public static void main(String[] args) {
Pattern p = Pattern.compile(args[0]);
Matcher m = p.matcher(args[1]);
boolean b = false;
while(b = m.find()) {
System.out.print(m.start() + m.group());
}
}
}

And the command line:

java Regex2 "\d*" ab34ef

What is the result?

  • A. 234
  • B. 334
  • C. 2334
  • D. 0123456
  • E. 01234456
  • F. 12334567
  • G. Compilation fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment