Reputation: 461
I have a pack of number say :
the full data always string int string, I use this to split it each group
string1 = ^(.*?)\D+
int2 = (\d+)
string3 = ([a - zA - Z] *$)
but I always gets an error if data only int string (example 123ss), since it's variable string1 reads the first digit, can anybody tell me where did I go wrong?
Upvotes: 4
Views: 6673
Reputation: 626689
To match 0 or more non-digit chars at the start of a string you need to define your string1
as
string1 = ^(\D*)
It will capture 0 or more non-digit (\D
) chars at the start of the string (^
).
The whole string pattern can look like
^(\D*)(\d+)(\D*)$
See the Regulex graph:
See also the regex demo.
Upvotes: 5