Regular expressions in HA config (like in "customize", "recorder")

There are some places in HA yaml config which accepts “*” to define patterns.
For instance:

customize_glob:
  sensor.temperature_*

This example defines an icon for all corr. helpers:

input_boolean:
  customize_glob_1:
  customize_glob_2:
  customize_glob_3:
  customize_glob_4:
  customize_glob_5:
  customize_glob_6:

homeassistant:
  customize_glob:
    input_boolean.customize_glob*:
      icon: mdi:car

But this does not seem like a “true” regex.
For instance, this does not work:

    input_boolean.customize_glob.*:

But this works:

    input_boolean.customize_glob*[1,5]:

and changes an icon for entities “_1” & “_5”.
This also does not work:

    /input_boolean.customize_glob.*[1,5]/:

So, seems that for this particular “customize_glob” option regex are not supported (and they are not mentioned in Docs).

But in Recorder docs regex are mentioned:

Has anyone defined “true” regex in Recoder config?
Or may be in “recorder.purge_entities” service (exactly where regex are mentioned in Docs).

Tested it myself with recorder settings & do not think regex is supported here…
This code

  exclude:
    entity_globs:
      - input_boolean.test_*

excludes all entities starting with “input_boolean.test_”, but not with “input_boolean.testing_” (i.e. the code does work) - but “test_*” is not a regex.
Does this mean that:
– either regex is mentioned in Recorder docs by mistake,
– or regex is only supported for “recorder.purge_entities” service,
– or THIS is also “some kind of regex” ? )))

I don’t believe they are intended to be regular expressions, except where it is explicity mentioned for the recorder.purge_entities service call.

In regex, the asterisk represents zero or more of the preceding character. Therefore, from a regex perspective, the sensor.weather_* example in the recorder documentation would match “sensor.weather_”, sensor.weather__", “sensor.weather___*” etc (ignoring the dot matches any character). This would be a really bad choice of an example.

I assume HA actually uses something like filename globbing, such that the asterisk matches zero or more characters by itself. The Ubuntu documentation doesn’t specifically support “[1,5]”, but trying it on filenames works. This then agrees with all the positive and negative examples you provided, with the proviso that HA effectively tacks another asterisk on the end.

Note that it looks like the States tab in Dev Tools is different again. It supports an asterisk, but not “?” or “[]”. In this case we*er matches “weather”, but w[a,e]*er or w?*er match nothing.

Not exactly.

input_boolean.test_*

will match (if regex)

test
test_
test__

but I said that this does not match in fact:

testing

So - “_*” is not same as “zero or several underscore characters”.
It proves that this is not regex. (unless “or THIS is also “some kind of regex””)

From regex101.com -

And nothing matches “testing”, so I’m not sure what you mean there. But regardless, regex is a distraction - HA is obviously not using it, and probably using filename globbing.

Check this:
изображение
You are right about “testing”. But - “test_xyz” does not match too (if regex) - but it does in fact (because this is not regex in Recorder config)

Oh yes, testing matches in regex. But why are you talking about regex - HA isn’t that. Except presumably where it’s specifically mentioned.

I am talking about regex because I was not sure what kind of patterns is used in HA.

Ah ok. Not regex, but probably filename globbing (except in Dev Tools), since that seems to match.

Current patterns used in places like “customize_glob” do not allow to EXCLUDE criteria (ot at least I do not know how to exclude).
I.e. “sensor.xyz_*” may be used, but w/o a possibility to exclude “sensor.xyz_bla_bla_bla”…