I'm trying to match different abbreviations for the german word "Straße" (e.g. "Str" or "Str.")
How can i escape the dot sign within the string?
\b(Str|Str.)\b
And how can i setup case-insensitive? It would be nice if the regex matches "str", "sTr", ... too.
You escape special characters with \
.
\b(Str|Str\.)\b
Also, ?
makes the preceding token optional, so we can condense to:
\b(Str\.?)\b
Finally, case insensitivity is specified with the i
modifier. How you specify modifiers depends on the language. In most cases they're put after the closing delimiter of the regex:
/\b(str\.?)\b/i
You can escape it by preceding it with a backslash. You can specify case insensitivity using an i
modifier.