Good day. Tell me, please, how can I implement the following idea in regular expressions:

All characters except the "=" sign, in front of which there is no "\" sign

I tried it like this, but did not achieve the proper effect:

(?<!\\)[^=]*

  • one
    Something tells me that you need a parser, and you are trying to do with regulars. - VladD

1 answer 1

If the question implies the full implementation of screening, then:

https://regex101.com/r/dG3bF4/1

 (?:\\.|[^=])+ 

It reads like this:
Alternative from any escaped character, or any character other than = at least 1 time.


And if you just need to capture all the characters, or = in front of which there is no \ , then so:

https://regex101.com/r/dG3bF4/2

 (?:[^=]|(?<=\\)=)+ 

It reads like this: a character other than = or = before which \ at least once.

  • Generally, (?:[^=]++|(?<=\\)=)+ and (?:\\.|[^=]++)+ will not work in .NET. Regex101 does not support .NET regular expression syntax. - Wiktor Stribiżew
  • Yes, it's to blame. I did not think that in NET there is no support for svadadnosti. Thank. - ReinRaus 7:55 pm
  • @ WiktorStribiżew was at work, went to the site when your answer was 4 minutes: ( - ReinRaus
  • Sorry :( I wouldn’t write the answer if you had a slash included in the match initially :( - ReinRaus