+ 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

9th Jan 2019, 12:55 AM
Ananya
2 odpowiedzi
+ 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.)
9th Jan 2019, 1:25 AM
Anna
Anna - avatar
+ 2
Anna Thank you!
9th Jan 2019, 1:28 AM
Ananya