python - Need regex for a period that's not between numbers -


need regex periods that's not between 2 numbers

it should match

  • happy1...

  • hello, world.

but should not match:

  • 1.2
  • holiday

this work you:

((?<!\d)\.|\.(?!\d)) 

it matches period isn't preceded digit ((?<!\d)\.) or (|) isn't followed 1 (\.(?!\d)).

actual python code:

import re p = re.compile(ur'((?<!\d)\.|\.(?!\d))') test_str = u"happy1...\nhello, world.\n1.2\nholiday"  re.findall(p, test_str) 

demo

please note: in future, should post have tried , why isn't working. questions seeking debugging ("why isn't code working?") must include desired behavior, specific problem or error , the shortest code necessary reproduce in question itself. questions without a clear problem statement not useful other readers. see: how create minimal, complete, , verifiable example.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -