I'm trying to get a regex to validate/extract from a string all the characters until the first dollar. If the string doesn't have any dollar,it should match the whole string but it doesn't work.
What i tested is:
System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match("12345678$1", "/[^\$]*/");
What i expect is to get in match.value => 12345678 If the string passed is for example 123456781 it should return everything.
What is wrong?
Thanks Best regards.
From what I am getting, the expression you are using will match any string which is made up from 0 or more instances of any non
$
character.You could try something like below:
Which matches and extracts any numbers up to
$
(denoted as\\$
) or else, the end of the string (denoted by$
), which ever comes first.