I want to remove dot (.) but I don't know how can I write this pattern.
I have some text line this.
E-1-2-3.1-0-0 or E-1-2-0-2.5-0 or E-1-2-0-3.5-0
But in my text some are numbers like 2.5, 56.7. I don't want to remove these dots are they are decimals.
Just if in lines then I need to remove dot. -5.2-
will be -52-
E-1-2-3.1-0-0
will E-1-2-31-0-0
E-1-2-0-2.5-0
will E-1-2-0-25-0
E-1-2-0-3.5-0
will E-1-2-0-35-0
There can inside has DOT or NOT.
Any help regarding this pattern ?
If you only need to match dots surrounded by dash-digit and digit-dash, try positive lookarounds:
(?<=-\d)\.(?=\d-)
Demo: https://regex101.com/r/nY7fA9/1
If you need to match dots surrounded by dash-digits and digits-dash (any positive number of digits), the thing is more tricky since lookbehinds do not support quantifiers in many regex flavors. In this case you may match the prefix with a normal regex and immediately reset the match with \K
:
-\d+\K\.(?=\d+-)