Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there equivalent to \Q ... \E in C# Regex

Tags:

c#

regex

Is there equivalent to \Q ... \E in C# Regex? I can't find it.

like image 723
StuffHappens Avatar asked Mar 09 '10 10:03

StuffHappens


People also ask

What is .*? In regular expression?

. *? is non-greedy. * will match nothing, but then will try to match extra characters until it matches 1 , eventually matching 101 . All quantifiers have a non-greedy mode: .

What will the '$' regular expression match?

By default, regular expressions will match any part of a string. It's often useful to anchor the regular expression so that it matches from the start or end of the string: ^ matches the start of string. $ matches the end of the string.

How do I find a character in regex?

There is a method for matching specific characters using regular expressions, by defining them inside square brackets. For example, the pattern [abc] will only match a single a, b, or c letter and nothing else.

Which function we use to match pattern in regular expression in r?

The regexpr() function gives you the (a) index into each string where the match begins and the (b) length of the match for that string. regexpr() only gives you the first match of the string (reading left to right). gregexpr() will give you all of the matches in a given string if there are is more than one match.


1 Answers

There is no direct equivalent to the \Q...\E syntax in .NET as told on this site.

Instead you could use the Regex.Escape method :

Escapes a minimal set of characters (\, *, +, ?, |, {, [, (,), ^, $,., #, and white space) by replacing them with their escape codes.

like image 125
Julien Hoarau Avatar answered Nov 06 '22 11:11

Julien Hoarau