Home > Back-end >  Why my regexp not working properly? End line dont working in my expression
Why my regexp not working properly? End line dont working in my expression

Time:10-20

Why my regexp not working properly? End line dont working in my expression

Exp: /. \[(acion)(=|>|<|>=|<=|!=|=|!=)\]"[a-zA-Z ]*" |[a-zA-Z] |"[a-zA-Z ]*"$/gm

result: <sple> [acion>]a [acion=]a

Look at the picture, there the first a is highlighted as valid, but I need the regular expression to see only the second a as valid. I think the problem is in the work of the end of the line, since I tell the expression to look only from the end and do not set the beginning

I will be glad of any help) Have a nice time.

enter image description here

CodePudding user response:

You only have $ in the last alternative, so it's the only part that has to match at the end of the line. The other alternatives can match anywhere.

If you want $ to apply to the whole expression, put a group around everything else.

/(?:.  \[(acion)(=|>|<|>=|<=|!=|=|!=)\]"[a-zA-Z ]*" |[a-zA-Z]  |"[a-zA-Z ]*")$/gm
  • Related