Python Regex

I have the below string and regex. However I cant understand why it works the way it does. IP has been changed for safety :wink:

String = NowSMS Error Report. Error initializing SMSC Interface 'SMPP - 10.15.8.10:17600'. Interface is not available.

Regex = (.+\.)\s(.+)

I get two backreferences as expected.

Group 1: NowSMS Error Report. Error initializing SMSC Interface 'SMPP - 10.15.8.10:17600'.

Group 2: Interface is not available.

Question:

Why doesn't group 1 = NowSMS Error Report. <------ stopping at first period

Your RE is open ended and has an overly aggressive match. You need to

  1. Anchor your regular expression to ensure that it works as you intend ( Tell it where the line starts or ends )
  2. Match the expression to what you want to capture, ie. don't assume that a wildcard match will do as you expect.

The expression you want starts with "not a period" not "multiple instances of any character"