-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Description
# Documentation
https://docs.python.org/3/library/re.html#re.Pattern
Using the data shown, it is not clear the difference between using "X" vs. "^X" as both results are the same.
Current text:
re.search("^X", "A\nB\nX", re.MULTILINE) # Match
re.search("^X", "A\nB\nX", re.MULTILINE)
<re.Match object; span=(4, 5), match='X'>
re.search("X", "A\nB\nX", re.MULTILINE)
<re.Match object; span=(4, 5), match='X'>
Recommended text change:
re.search("^X", "AX\nBX\nXC", re.MULTILINE) # Match
re.search("^X", "AX\nBX\nXC", re.MULTILINE) # Match
<re.Match object; span=(6, 7), match='X'>
re.search("X", "AX\nBX\nXC", re.MULTILINE) # Match
<re.Match object; span=(1, 2), match='X'>
With the ^ the search picks up the X at the beginning of the line at position 6.
With no ^ the search picks up the X at position 1.
Metadata
Metadata
Assignees
Labels
Projects
Status