make perl-style regex interpreter act simple extended regex interpreter
i am minute apparatus assistance students learn unchanging expressions. i substantially minute java.
the thought this: tyro forms unchanging countenance apparatus shows tools calm matched regex. rudimentary enough.
but i wish support several opposite regex "flavors" such as:
- basic unchanging expressions (think: grep)
- extended unchanging expressions (think: egrep)
- a subset perl unchanging expressions, including impression classes \w, \s, etc.
- sed-style unchanging expressions
java java.util.regex class, nonetheless supports wholly perl-style unchanging expressions, superset simple extended res. i cruise i need proceed take any given unchanging countenance evade meta-characters aren't biased given flavor. following i give regex vigilant act combined comparison re interpreter.
for example, given following regex:
^\w+[0-9]{5}-(\d{4})?$
as simple unchanging expression, interpreted as:
^\\w\+[0-9]\{5\}-\(\\d\{4\}\)\?$
as an extended unchanging expression, be:
^\\w+[0-9]{5}-(\\d{4})?$
and perl-style regex, same uncanny expression.
is there "regular countenance unchanging expressions" i run by regex search-and-replace quote non-meta characters? else i do? there choice java classes i use?
Comments
Post a Comment