Reputation: 2287
I have the regular expression:
[^\w-,.]|((?<!\d)[,.]
which matches all non [\w-,.]
or, using a negative lookbehind, any comma or period not preceded by a digit.
Using java-compatible regex, I need to capture:
[^\w,.]
,
unless preceded and followed by a \d
1,2,3
but capture [\s,]
in 1, 2, 3
).
unless preceded and followed by a \d
12.32
but capture for 23.
)My regex gets me close, however, I am not able to capture the commas and periods in the following examples:
1.a
(need to capture the period)32, foo
(need to capture comma and whitespace)1.1.
(need to capture the last period)The following example illustrates example of working and non-working strings to match.
https://regex101.com/r/pWcwXa/2
Upvotes: 2
Views: 1099