Reputation: 1441
I am trying to write this regex to match dots with a few rules
(\.+ *|([a-zA-ZÀ-ž]\.\d))(?=[^\d{1}(\.\d{1})])(?=[^.,])
But my regex is matching few characters before and after the dot as well
For example:
č.1 > match č.1 (incorrect, match should be only .)
St.M > match . (correct)
2.0 > no match (correct)
Do you have any idea, how to "exclude" these other characters from the result and match only the dot?
Thanks for your help
Upvotes: 1
Views: 431
Reputation: 163632
You could shorten the pattern using a positive lookbehind (?<=)
asserting the character class with the specific ranges to the left.
(?<=[a-zA-ZÀ-ž])\.
As per the comments, the pattern with the positive lookahead
(?<=[a-zA-ZÀ-ž])\.+ *(?=[^.,])
Upvotes: 2