Java flavor
Any change of support for java?
Thanks for the great job.
Still no success :(... I could host it on a server, but that would defeat the purpose.
I just want to leave +1 for that feaure request as your online tool is the coolest tool for regular expressions I ever seen. I'd love to see the ability to construct regexps for java in it.
+1 I do a lot of regexing in Java and this would be nice to have. Also, Ruby and .NET if possible :3
Donated hopefully <3
+1 for idea. The differences between Java and PCRE is that several constructs are absent ((|, (?(condition)), presence of intersection classes and character set are presented differently (\p{Upper}, \P{Upper}), really. Is this possible by basing off Perl?
As mentioned by the official documentation:
The Pattern engine performs traditional NFA-based matching with ordered alternation as occurs in Perl 5. Perl constructs not supported by this class: [...] Constructs supported by this class but not by Perl: [...] Notable differences from Perl: [...]
Also, idea for code generation:
Pattern re = Pattern.compile( /* Pattern here with literals escaped */);
String str = /* String here */;
Matcher obj = re.matcher(str);
while (obj.find())
System.out.println(obj.group());
@Vincentyification I could create a syntax parser for Java and use the PCRE engine underneath. It's probably not going to work identically to Java, but pretty damn close and it will check the syntax for people.
@firasdib That's a great idea, and possibly close to where I was originally going. Since the Java Pattern syntax doesn't change frequently (In fact, since it was established on Java 5 it never changed), any maintainable implementation would work for this case. I thought of this while searching for a Java library which could parse PCRE, but got sidetracked seeing http://regex101.com having an exclusive bullet point documented by Wikipedia under "Links" section. I thought since Java syntax is based on Perl, a short regex could be used to check for invalid syntaxes that wouldn't apply in Java, and converting Java-style character classes to Perl. [[:hex:]] -> \p{XDigit}, et cetera. As for the class intersections, I think you could get away by converting them to positive / negative lookaheads and faking the relevant sections in the "regex debugger". As for the related ticket about Ruby regex support, there's a bigger issue in the syntax similarities, so I'm only suggesting a parser for Java input for now.
+1
+1. I missed out on this post and created a new one. Please disregard that.
Thanks.
@Vincentyification: There are lots of f*ck up things in the reference implementation (Oracle and OpenJDK) of Java regex that wouldn't present in PCRE. For example: negation of negation of character class, definition of \b not based on \w, capturing group manage to capture stuffs in negative look-around, incorrect retention of captured content, integer overflow in length calculation to limit look-behind, high stack usage leading to StackOverflowError for greedy repetition, ... (CANON_EQ not mentioned here, since it is a buggy and unusable feature). It will cause confusion for user if you use PCRE implementation here.
@nhahtdh +1 Great points!
+1 for explicit Java support
Support for intersections in Java would be great: http://www.regular-expressions.info/charclassintersect.html (Just made a small donation re this feature)
+1 please add this
:+1:
The new release will feature a code generator for Java which might help some, alteast with those pesky backslashes. The PCRE engine is still as close as you're going to get, which is likely going to cover it for most of your cases. But so far I have not been able to get the actual engine running. Sorry!
me too
Hi everybody! I just managed to compile the Java regex engine to javascript by taking the engine from the openjdk (java.lang.Pattern, java.lang.Matcher, etc.) and running TeaVM on it. I've sent my work to @firasdib, so hopefully he'll get it working soon :pray: :smile:
It's currently based on java 8, does anybody know if there is any relevant changes made to the engine since then?
@simonlindberg As far as I know, yes there were some changes made to the regexp engine after Java 8 : https://bugs.openjdk.java.net/issues?jql=project%20%3D%20JDK%20AND%20status%20in%20(Resolved%2C%20Closed)%20AND%20resolution%20%3D%20Fixed%20AND%20component%20%3D%20core-libs%20AND%20Subcomponent%20in%20(java.util.regex%2C%20java.util.regex%2C%20java.util.regex%2C%20java.util.regex)
@OlivierJaquemet Looked at a few and most of them seems to be performance related or regressions i later version. I did find one that might be related, https://bugs.openjdk.java.net/browse/JDK-6609854 , might be more like it. But since Java 8 still is the most popular version I think in that case there should be multiple java flavors available (all the LTSs perhaps?). As long as the version is clearly stated I think only Java 8 is a good start! :)
Thanks to the work by @simonlindberg, you can expect regex101 to support java shortly! Keep a close eye on the website the coming days...