In Python, you try to find if the string contains "a something:" as a regular expression.
import re
re.match(r'a[\s\w]+:',"a something:")#a preceded by a space
This will result in None.
import re
re.search (r'a[\s\w]+:',"a something:")
If I do it, the results come out well. I know that there is a difference in the number of matches and search. Is there a difference in the search method?
regex python codesquad
Match checks to see if it matches from the beginning, and search finds it everywhere. That's why I couldn't find you if there was a gap at the beginning.
© 2024 OneMinuteCode. All rights reserved.