i’m doing the simplest regex.match ever, i am giving the Regex.Match a pattern of one character and it returns no match at all, and i made sure the input text contains a lot of that character?
i checked all the usings.
its just very weird.
any help would be appreciated!
Thanks.
EDIT:
my sample is “doing any type of matching is simply not WORKING”
returns an empty match
Match m=Regex.Match(@"c","abcdc");
the code is compiled with no errors, so why the NO MATCHING!!
EDIT: based on your edit the issue is that you’re using the parameters out of order. You need to switch the order and supply the input (string source to find a match in) then the pattern (what to match against).
In fact, this order is specified for you by the IntelliSense as depicted in this image:
It usually helps to match the naming suggested by the IntelliSense or refer to it to ensure the proper items are being passed in.
What is the character being used? Chances are you’re trying to use a character that is actually a metacharacter which holds special meaning in regex.
For example:
The above wouldn’t return anything since
$is a metacharacter that needs to be escaped:For a list of common metacharacters that need to be escaped look at the Regex.Escape documentation.