JRX is inspired by the RX tool of ActiveState's Komodo IDE. Although RX is more powerful and supports Perl Regular Expressions (almost?) fully, I've needed an always-accessible and installation-free implementation.
So, here it is: a single, ultra-compact HTML file, without any external file ;)
Save it to your disk if you like, or use online for latest version.
You might also be interested in Ted Mielczarek's Extension Developer's Extension, it includes JRX among some other very useful stuff, it's terrific!
This is not an AJAX application, you can save the page locally and use it off-line.
I'd tested older versions of JRX with Mozilla 1.3, IE 6.0 and Opera 7.1, and JRX worked OK in all of them.
However, IE6 and Opera have had back then some funny bugs with JavaScript and CSS, and I'm getting tired of IEs inferior CSS/JS-support (I'm not sure of IE7, I don't have it).
Therefore, I was testing the latest versions only with Mozilla Firefox >=v1.5; JRX may or may not work in Opera.
I'd be happy if you can come up with code submissions which fix things with IE/Opera, but most likely I will not do it myself.
I'm still keeping the latest working version for IE/Opera anyway.
Have fun.
Unless new bugs are discovered, I'll add no more features to this beta and release it as final.
I'm considering to add a few other tools and cosmetic changes, such as:
Though these might be useful to do everything on one place, it will also bloat the page, so they might be never implemented.
Q. Why are my results shown twice, if I use global and parentheses?
A. Results always include $0, which means, if you use, e.g. (^.*$), $0 is implicitly the whole matched string and $1 is your backreference!
Now if you pack your whole regexp into parentheses, $0 & $1 will be naturally the same, therefore shown twice:)
...try the above regexp with multiline(m) & global(g), and you'll see.
Results show only $0 now, hover over the results to see the substrings.
Q. What does "Eval target text" do?
A. It substitutes escaped chars \t \r \n \f \v with their respective values, before matching the regexp!
To see this in action enter "foo \t bar" as target text and "(\S+)(\s+)(\S+)" as regexp
and try matching with and without this options.
Note that the inline linebreaks in the target are not escaped; you should use \n in that case.
Also note that the highlighting does not function well when this option is active, yet.
Q. Why is text length shown "incorrectly" if use newlines?
A. (Firefox') HTML textareas interpret Enter key as ASCII code 0x0A (aka \n) and "a<ENTERKEY>b" returns a length of 3 whereas other editors show a length of 4 using 0x0D+0x0A (aka \r\n).
So be cautious if text length is extremely important for you and/or if you match/split by \n, \s, etc.
Q. How can I backreference inside my regexp?
A. For example, to match ISO-type dates (yyyy-mm-dd) you could use (\d{4})([/.-])(\d{2})\2(\d{2}) (this is a practical example, but not validating). Note the \2 it ensures that the same delimiter is used afterwards.
BTW, a complete date-validating regexp is nearly impossible, due to the leap years, but an approximate solution would be:
(\d{4})([/.-])(0\d|1[0-2])\2([012]\d|3[01]), though this would match 9876-02-30, too, I'll leave the rest as an exercise.
You can recognize shortcuts on underlined letters. Firefox used to have ALT as modifier key and later versions use ALT-SHIFT.
Modifier-E | Expression box | |
Modifier-T | Target text box | |
Modifier-A | About | |
Modifier-G | Global matching | |
Modifier-M | Multi-line mode | |
Modifier-S | Single-line mode | |
Modifier-I | Ignore case | |
Modifier-I | eXtended regexps | |
Modifier-P | sPlit mode | |
Modifier-R | Replace mode | |
Modifier-C | Compact mode | |
Modifier-H | sHow mini reference |
\d | any decimal digit |
\D | any char that is not a decimal digit |
\s | any whitespace char |
\S | any char that is not a whitespace |
\w | any word char |
\W | any non-word char |
\b | word boundary; inside char-class: backspace |
\B | not a word boundary |
\A | start of subject (independent of multiline mode) |
\Z | end of subject or newline at end (independent of multiline mode) |
\z | end of subject(independent of multiline mode) |
[] | char class |
^ | beginning of line; inside char-class: negate |
$ | end of line |
() | capturing parentheses |
| | alternation |
* | zero or more time, equals to {0,} |
+ | one or more time, equals to {1,} |
? | zero or one time, equals to {0,1} |
{m,n} | preceding char or group minimal m, maximal n times |
(?:) | non-capturing parentheses |
(?=x) | lookahead, i.e. only if followed by x |
(?!x) | negated lookahead, i.e. only if not followed by x |
(?<x) | |
(?<!x) | |
\f | form-feed |
\t | tab |
\v | vertical-tab |
\r | carriage return |
\n | new line (unix:\n, win:\r\n, mac:\r) |
\xhh | hexadecimal code of char (2 hex) |
\uhhhh | unicode code of char (4 hex) |
Distributed under GNU License.
Modifications are allowed as long as credits are preserved and visible,
i.e. you may not re-distribute this page in its compact form, i.e. with page header and footer being hidden!
Email portion of this program courtesy of: Jim Tucek
Other portions of code which are used in this page are fully documented and credited in the source code.
Finally /s & /x and named captures, thanks to XRegExp!
\d any decimal digit \D any char that is not a decimal digit \s any whitespace char \S any char that is not a whitespace \w any word char, i.e. [A-Za-z0-9_] \W any non-word char, i.e. [^A-Za-z0-9_] \b word boundary; backspace inside [] \B not a word boundary \A start of subject (independent of multiline mode) \Z end of subject or newline at end (independent of multiline mode) \z end of subject (independent of multiline mode) \1..n backreference inside the regexp [] char class - range separator in char class ^ beginning of line; negate inside [] $ end of line () capturing parentheses (?:) non-capturing parentheses | separator btw. alternatives * zero or more time, equals to {0,} + one or more time, equals to {1,} ? zero or one time, equals to {0,1}; non-greedy modifier after *+?{} {m,n} preceding group: min m, max n times (?=x) lookahead (only if followed by x) (?!x) negated lookahead (only if not followed) (?<=x)lookbehind, not supported by JS (?<!x)negated lookbehind, not supported by JS \f form-feed \t tab \v vertical-tab \r carriage return \n new line (unix:\n, win:\r\n, mac:\r) \xhh hexadecimal code of char (2 hex) \uhhhh unicode code of char (4 hex) Complete reference
Your browser doesn't support CSS, please upgrade!