Let’s say the original text is something like this:
12345 {unit}
Then what’s the regex pattern for removing {unit} part and only keeping the numbers? Note that the length of unit can be random. Thanks.
EDIT:
well I had thought about using \d+, but I guess it would fail if the number part contains some kind of separators, e.g. 1000 separator. So if the number looks like this, 12,345 then the pattern \d probably wont work.
This function will return null on failure to match otherwise the matched value string.
You could also then parse the result through int.parse to get an int
If the result could be decimal (as opposed to integer then the match line would read
If you were using the decimal value you would then use the appropriate decimal.parse method