+ 1
Regex: matching special characters lesson doubt.
string: 1 + 3 * (2 + 2)+789 regex: 1 \+ 3 \* \(2 \+ 2\). output: 1 + 3 * (2 + 2)+ that's the output the 'try yourself' is generating. why does the output stop at + and not print 789? link to lesson: https://www.sololearn.com/learn/9795/?ref=app
2 Answers
+ 5
You added a . to the regex, that's why the + is matched. If you want it to match 789 as well, add a * to the regex (or something like \d*, \d+, \d+\b etc.)
+ 2
Anna Thank you!