Closed PrincessRTFM closed 8 years ago
A tip: if you use Intellij, pasting into a string literal will add the extra backslashes automatically.
I use Eclipse, which can do the same, but I prefer to keep it off so I can paste string literals from other sources without mangling them.
@Princess put your expression in an external text file, but I was actually about to post this exact same request. Is it possible to mod regex101?
@chrisgotter We're working on a version 2 of the regex101 site right now. While we have not yet found a Javascript solution to emulate a Java regex, we may be able to figure out enough in the meantime to be able to produce a Java-compatible (or "compatible-enough to get by") code generator
dump. It's still up in the air, but if you find any .NET, Java, or Ruby regex support which can port into Javascript (so the entire regex101 site can be used offline), by all means: post a github link and let us know.
so the problem is the code generator not the ui?
The main problem I'm having is that I have to double backslashes in Java strings, which I then pass to java.lang.regex.Pattern.compile(String[, int])
to make the regex. The biggest thing I'd like to see in "Java mode" is handling of that, so that \\[
represents a literal [
instead of the literal sequence \[
as it does now. That would prevent me needing to fiddle with the backslashes when copying from the site into my project, and (more importantly) when copying a regex from my project into the site for testing.
paste it into the test area then put this \\\\
in the expression area and \
in the replace area. Then paste the output into the expression area.
Best would be to create add a code sample for this that gets generated for you and fixes the backslashes.
Java strings require that backslashes used to escape metacharacters be themselves backslashes, such as
\\(.+?\\)
to match anything inside literal parens. I love the site, and use it for pretty much all of my regex testing, but it's annoying to have to escape my backslashes for java work when copying a tested regex into my project.