I have a question about a regex. Given this part of a regex:
(.[^\\.]+)
The part [^\.]+ Does this mean get everything until the first dot? So with this text:
Hello my name is Martijn. I live in Holland.
I get 2 results: both sentences. But when I leave the + sign, I get 2 two characters: he, ll, o<space>, my, etc. Why is that?
Your regex
.[^\\.]+means:[^\\.]means NOT slash or NOT dot, which means either a dot or a slash is not a match. It will keep on matching characters until it founds a dot or slash because of the “+” at the end. It is called a greedy quantifier because of that.When you input (quotes not included): “Hello my name is Martijn. I live in Holland.”
The matches are:
Note that the dot is not included in the first match since it stops at n in Martijn and the second match starts with the dot.
When you remove the +: (
.[^\\.])It just means: