TasmotaManager/docs/summaries/regex_dot_explanation.md
2025-10-28 00:21:08 +00:00

856 B

Explanation of "." in Regex Patterns

In the exclude_patterns section of the network_configuration.json file, you have patterns like:

"^.*sonos.*"

What does the "." do in regex?

In regular expressions (regex):

  • The "." (dot) matches any single character except a newline character
  • It's different from "*" which is a quantifier meaning "zero or more of the preceding element"

Breaking down the pattern "^.sonos.":

  • ^ anchors to the beginning of the string
  • .* means "zero or more of any character"
  • sonos matches the literal string "sonos"
  • .* again means "zero or more of any character"

This pattern matches any string that starts with any characters (or none), contains "sonos", and may have any characters after it.

Examples of matching strings:

  • "sonos"
  • "sonosdevice"
  • "mysonosspeaker"
  • "new-sonos-system"