RM: Best way to search for multiple matches in a single string?

Hi All, is there a smart way to search a single block of text for multiple strings in RM without defining a condition for each search?

eg, I use the OpenWeather Alerts to change my Powerwall battery reserve level when severe weather is predicted, but my brute force method is ugly AF eg

Im hoping there is a way to create a list of search strings and then recursively search the same custom attribute for them?

Cheers Derek

I'm afraid not directly, but the method I was going to recommend -- namely breaking an existing/result String var into pieces using Token -- probably won't apply (cleanly) to this use-case either. I'm leaning strongly toward recommending WebCoRE as an able(r?) alternative for its built-in text- and JSON-handling abilities, plus indexing( ).

But would you mind pasting a typical input, along with a screenshot or two of how you want the result(s) to look and what you've already tried in RM (even if it's ugly, lol)?

EDIT: OMG, at first I couldn't make out what your OP screenshot showed -- thinking it was just a sample input text block -- but I now recognize that it's a collection of OR'd actions in RM. Gonna need a microscope. :smiley:

1 Like

lol, itā€™s not actually complex, itā€™s just 6 individual search operations on the same wall of text.

If it matches any of the strings, it sets a Boolean hub variable to true, otherwise it sets it to false.

Maybe turn this off just so we can see your rule setup without the copies of the blob? I'm still working on a good answer for you, btw. Life intervened.

1 Like

Cheers, Iā€™m at work, but Iā€™ll do that tonight.

1 Like

This is rough but it works, and does so in essentially N-time without much fuss, plus is easy to maintain by simply editing/adding more "MatchN" local string vars (with values like Damaging winds, etc.) to the rule along with its corresponding "Replace" action.

If you need the check to be done against attributes from more than one device, as suggested in your OP, simply duplicate the second Action and provide an InputB var for its target, then concatenate all the sources (Input, InputB, ..) back into Input early on.

Result is a scalable rule without thorny IF-THEN-ELSE, OR'ing or loops.
If you'd like me to expand on what's behind each step, just ask!

2 Likes

Cheers, Iā€™ll have a look tonight when I get home.

Cheers for the concept, I think that is much easier to manage. :+1:

1 Like