I’ve got a number of different string that look something like:
- 1
- 1,2
- 1 2
- 1 and 2
- 1, 2 and 3
- 1, 93
So thats:
– single numbers (potentially multiple digits)
– sequences seperated by ‘and’, commas or spaces
I’d like to write a Reg Ex to pull back just the numeric bits of the string. I had thought something like this would work:
Pattern.compile("^(?:(\\d+)[^\\d]+)*$");
The idea being that it should match and capture sequences of digits, skip multiple non-digits characters and repeat
Are you not just doing a match on digits here?: