I am stuck in a dump:
import re
print re.search('return[^$]+',
'return to the Treasury of $40 million\nnow!').group(0)
The above regex only prints return to the Treasury of, but I expected it to include $40 million. What I understand from regex is that I am asking it to take every thing until the end of the line.
I do not want to use .*, I want endline delimiter to go until the end of line from some point. If I remove $ from search string it prints the full string. Why is endline delimiter matching with dollar sign??
will match a string “return” followed by any character that is not ‘$’ one or more times.
This is because [ ] mean character group and inside [ ] the special characters are threaded as simple characters.
Thus it matches only until the the dollar sign.
Why not use:
this is exactly what you want.