The obvious difference between b / w Java and Python is that in Java you need to avoid a lot of characters.
In addition, you are likely to encounter a mismatch between the matching methods, and not the difference in the actual record in the regular expression:
Given Java
String regex, input;
- Java
matcher.matches()
(also Pattern.matches( regex, input )
) matches the entire string. It has no direct equivalent in Python. The same result can be achieved using re.match( regex, input )
with regex
that ends in $
. - Java
matcher.find()
and Python re.search( regex, input )
correspond to any part of the string. - Java
matcher.lookingAt()
and Python re.match( regex, input )
correspond to the beginning of the line.
For more information, also read the Java Matcher
documentation and compare with the Python Documentation .
Since you said that this is not a problem, I decided to do a test: http://ideone.com/6w61T It seems that java does exactly what you need (group 0, full match, does not contain ;
). Your problem is elsewhere.
source share