Skip to content Skip to sidebar Skip to footer

Regex: Match Fullstop And One Word In Python

I am new to regex. I wish to write a regex which matches a '.' followed by a whitespace followed by a word(which does not contain whitespace. For example, in the string 'The sound

Solution 1:

import re
input = 'The sound of cracking. Splintering. A shape appears, in ice.'print re.findall("(\.\s+[a-zA-Z]+)", input)

Output: ['. Splintering', '. A']

Solution 2:

Try:

(\.\s\w+)

Matches:

. Splintering

. A

See it in action.

Post a Comment for "Regex: Match Fullstop And One Word In Python"