Hello I would like to have a regex which matches anything but the line ending with comma followed by 0 or more spaces. Please test it before giving me the solution. I initially thought it is easy and later felt difficult to solve it.
1) this is an example - should match
2) this is an example, - should not match
3) this is an example, - should not match
4) this is an example - should match
The solutions you provided is using the control features from PERL language to match the other lines and isolate the required ones in the else block. I just wanted to have the regex matching in the if block itself and not in the else block.
For instance, we can check our regex in this website
to see its validness.
I can think of a solution which is close to Moritz solution.
My regex is ^(?!.*,\s*$)
The ?! is used for negative lookahead.
Do you guys think of any other alternatives to achieve this. Please don't use the programming construct. Just focus on the REGEX alone.
Thanks & Regards,