Regex Question: How to search for "$"...
-
Can someone give me an example pattern that matches: $1.25 I can't seem to figure out how to match a literal "$" as it's not a valid escape character... Thanks!
~Nitron.
ññòòïðïðB A
start -
Can someone give me an example pattern that matches: $1.25 I can't seem to figure out how to match a literal "$" as it's not a valid escape character... Thanks!
~Nitron.
ññòòïðïðB A
start -
Can someone give me an example pattern that matches: $1.25 I can't seem to figure out how to match a literal "$" as it's not a valid escape character... Thanks!
~Nitron.
ññòòïðïðB A
startNitron wrote:
match a literal "$" as it's not a valid escape character...
As the other responses suggest, you should be able to escape the $. An alternative is to put it like this: [$] instead of escaping it.
-
Can someone give me an example pattern that matches: $1.25 I can't seem to figure out how to match a literal "$" as it's not a valid escape character... Thanks!
~Nitron.
ññòòïðïðB A
startYou have to distinguish between Regex escape characters and C# escape characters. If you escape a character for a Regex, you have to prefix it with a \. To write a \ in C#, you'll have to add another \. So you'll have to use "\\$" or @"\$" in C#
-
Can someone give me an example pattern that matches: $1.25 I can't seem to figure out how to match a literal "$" as it's not a valid escape character... Thanks!
~Nitron.
ññòòïðïðB A
startYou may be able to just use Decimal.Parse if all you have is a money string.
File Not Found
-
You have to distinguish between Regex escape characters and C# escape characters. If you escape a character for a Regex, you have to prefix it with a \. To write a \ in C#, you'll have to add another \. So you'll have to use "\\$" or @"\$" in C#
-
You have to distinguish between Regex escape characters and C# escape characters. If you escape a character for a Regex, you have to prefix it with a \. To write a \ in C#, you'll have to add another \. So you'll have to use "\\$" or @"\$" in C#