I have a text input that will be input like the following
7 - BMW 550i
If the user inputs this, how can i use a regular expression to remove all the content on the right of the dash character so all i am left with is the first numerical value.
I have tried this:
-?\\d+
But if like the example i gave it will get the end numbers.
This should work:
Use
$1to get your result.For example, in Perl, use this:
RegexPlanet Online Demo.