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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -