What is the regular expression for . and .. ?
if(key.matches(".")) { do something }
The matches accepts String which asks for regular expression. Now i need to remove all DOT's inside my MAP.
in regex is a metacharacter, it is used to match any character. To match a literal dot in a raw Python string ( r"" or r'' ), you need to escape it, so r"\." Unless the regular expression is stored inside a regular python string, in which case you need to use a double \ ( \\ ) instead.
The character + in a regular expression means "match the preceding character one or more times". For example A+ matches one or more of character A. The plus character, used in a regular expression, is called a Kleene plus .
Yes, the dot regex matches whitespace characters when using Python's re module.
. Your regex starts with (?= (ensure that you can see, but don't consume) followed by . * (zero or more of any character).
. matches any character so needs escaping i.e. \.
, or \\.
within a Java string (because \
itself has special meaning within Java strings.)
You can then use \.\.
or \.{2}
to match exactly 2 dots.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With