0

I want to match the following string using regular expressions in Java:

suspicious url test' xts#dfd

I don't want the regex to match if there is a quote, (') This is what I'm using.

suspicious url\s.*(?!')

When i use this I match the whole string.

3
  • This depends completely on what kind of regex you are using. Are these POSIX? EREGex? Perl? Sed? what?
    – terdon
    Jun 13, 2013 at 13:11
  • @terdon java...it uses java regex to match it.
    – asadz
    Jun 13, 2013 at 13:12
  • This question appears to be off-topic because it is about Java programming.
    – slhck
    Jul 23, 2013 at 14:13

1 Answer 1

3

The problem is that the .* will match everything before the look ahead even happens. If you just want to make sure that a ' does not follow until the end of the line try:

suspicious url\s[^']*$

Not the answer you're looking for? Browse other questions tagged .