0

I am trying to match a pattern in Pandas using regex

The pattern is a sequence of alphanumerics, separated by a hyphen

s1 = pd.Series(['b064571d-9d72-4225-8ccf-5528622c5680', 'dog', 'house and parrot', '23', np.NaN])

The first element in the series is the pattern I want to match (8x - 4x - 4x - 4x - 12x, where x is an alphanumeric character)

I have tried

s1.str.contains('[^a-zA-Z0-9]', regex=True)
0     True
1    False
2     True
3    False
4      NaN

But I dont know the syntax for the 8 - 4 - 4 - 4 - 12 pattern? Any help appreciated thanks

Michael K
  • 355
  • 3
  • 9

0 Answers0