I’m under the impression that the Dot ‘.’ (wild card) character is dangerous to use. Is my fear unfounded? Thanks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only tricky part I see for ‘.’ is when matching multi-line string: with the wrong options, it can match much more than needed, and it can introduce bacjtracking issue (due to a non-greedy match).
From regex tutorial
The dot matches a single character, without caring what that character is. The only exception are newline characters.
In most regex flavors, the dot will not match a newline character by default. So by default, the dot is short for the negated character class [^\n] (UNIX regex flavors) or [^\r\n] (Windows regex flavors).
This exception exists mostly because of historic reasons. The first tools that used regular expressions were line-based. They would read a file line by line, and apply the regular expression separately to each line. The effect is that with these tools, the string could never contain newlines, so the dot could never match them.