tags:

views:

38

answers:

2

I am trying to find a regex that will do the following

Return true if a string ends with jaxws.managed but does not contain delegate.

eg

abc/delegate/xyz/jaxws/managed should return false, while

abc/def/xyz/jaxws/managed should return true

I tried using the regex

([^(delegate)])+([a-z]*[\\/]jaxws[\\/]managed[\\/])+

but it fails . Any help is much appreciated

+1  A: 

Assuming Java regex,

^(?!.*delegate).*jaxws/managed$
KennyTM
+1  A: 

You should specify what regex engine you're using.

Nevertheless...

return false if it contains "delegate" anywhere: /delegate/; -> return false

if we don't return, and it ends in "jaxws/managed", return true: /jaxws\/managed$/; -> return true

if you're using Perl, I suggest applying m{} instead of // to avoid the "leaning toothpick syndrome". Refer to perlre for more information.

guidj0s