1

I'm new on this topic for python 3.6. What is the difference \S*..\S* and \S+..\S+?

**import re
s = 'A message from csev@umich.edu to cwen@iupui.edu about meeting @2PM'
lst = re.findall('\S+@\S+', s)
print(lst)**

[a-zA-Z0-9]\S*@\S*[a-zA-Z]
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
user234568
  • 741
  • 3
  • 11
  • 21

1 Answers1

1
  • \S means it will match non-whitespace characters.
  • + means it will match 1 or more of the preceding token.
  • * means it will match 0 or more of the preceding token.

So in that case the \S+ means it will match 1 or more non-whitespace characters where as \S* will match 0 or more.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445