Please explain me this regex -


I've been studying Reggae for a few days with a special look. I can not understand this regex that "bar" does not match.

  ^ (?!. * Bar). * $   

I do not understand why . * Bar is used if someone can give me a better explanation which would be very helpful to me. Thank you ....

A

So, if at the specified point (your In the example, the line that specifies the beginning of ^ ), the pattern in the letterhead matches matches, the whole match fails.

See, you have . Bar is . If . * Bar matches, the whole regex fails.

When . * Bar match? The answer will be that whenever the bar is in the line, it matches:

  bar foo bar foo bar baz   

We say that no was not there. * . Thus, if you only match the bar in the negative signal, the whole match fails. Now, remember that this check is in the beginning.

^ (?! Bar). * $ will stop a match at the beginning of only one line, but ^ (?! *. Bar). * $ will stop Bar

Hopefully, it makes a bit obvious :)

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -