1

Just testing out some special regex characters and just came across some behaviour I could not explain. An un escaped full-stop stands for any character, therefore (for example) matching 3 to "." returns true, however, when I match 3 to "[.]", it returns false. What is the cause of this?

2 Answers 2

4

Like most other metacharacters, . loses its special meaning in a character class (the []). There, it just means "a dot".

Sign up to request clarification or add additional context in comments.

Comments

1

Inside the squares "." means full-stop and not any char.

So the regex "[.]" match "." and not "3".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.