Expert Refresh

Any character

1) Which one matches any character?




2) Which one matches one dot?






Any character

The metacharacter /./ is a shorthand for a character class that matches any charater.

Example

For example if you want to match 19.03.76, or 19-03-76 you can use /19[-.]03[-.]76/ However you might also try simply using /19.03.76/ In the regex /[-./]/ the dots are not metacharacters because they are within a character class.

Knowing the target

It's important to know that each dot can match any character at all, even a lottery number: 19 203319 7639 /19.03.76/ is easy to understand, but vague. Knowing the target text well is an important part.


References