I am trying to extract numbers before string on C#. Not numbers between or after strings. Only number before string.
I need theese results.
- dorosły ==> 0 or ""
- dziecko 0-3 lata ==> 0 or ""
- 1-osobowy quad ==> 1
- 9-osobowy quad ==> 9
I tried Regex on C# but I got "";
string test =Regex.Match("1-osobowy", @"/^(\d)-.*/m").Value;
>Solution :
try this:
string test = Regex.Match("1-osobowy", @"^\d+").Value;