5 ms·
I may be wrong but I'm fairly sure that /ab+/ would not match the string "abc". I might just be using a different library but /ab+/ would match "ab", "abb", "ab
by adinobro 17y ago
I may be wrong but I'm fairly sure that /ab+/ would not match the string "abc". I might just be using a different library but /ab+/ would match "ab", "abb", "abbb", etc. The plus means one of more of the previous character. /ab?/ would match "abc" though...
- khafra 17y agoIt'd match the string, the same way /a/ would match "abcdefg." grep -o /ab+/ would only show "ab" from "abc" iirc, /ab(?![^b]+)/ would match "abb" but not "abc"
- cousin_it 17y agoThe regular expressions built into many programming languages have the semantics of matching any part of the string, not necessarily the whole string. If you want to match the whole string, you're supposed to put ^ at the beginning and $ at the end, or something like that.