Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

closed as off-topic by slhck Jul 23 '13 at 14:13

  • This question does not appear to be about computer software or computer hardware within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

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

1 Answer

up vote 3 down vote accepted

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[^']*$
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.