Answer the question
In order to leave comments, you need to log in
Is it possible to specify a safe zone in regular expressions?
Good day.
Tell me, is it possible to specify a "safe zone" in C# in regular expressions, i.e. so that Regexp does not work in this zone (for example, between two arbitrary characters).
I'll give you an example.
I have a string '2+'+'3=5', it needs to be divided by pluses, but only so that the pluses in apostrophes remain there, i.e. as a result, you need an array of three elements (two parts of the string and one separator):
'2+'
+
'3=5'
First of all, the Regexp solution is of interest, but if there are alternatives, except for passing through the string and comparing, then please share.
Answer the question
In order to leave comments, you need to log in
Here's how I got it
foreach(var substring in Regex.Split("'2+'+'3=5'", @"'\+'").Select(s => s.Trim('\'')))
Console.WriteLine(substring);
2+
3=5
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question