Regex and matches, expressions.

Post your questions and help other users.

Moderator: Martin

Post Reply
dragon
Posts: 29
Joined: 10 Sep 2015 08:13

Regex and matches, expressions.

Post by dragon » 23 Sep 2015 20:37

How to I form an expression where IF the variable contains the word "cloud" (REGEX) then the condition can be true or false?

awdescription=matches(weather, "(?I).*rain.*")

...is what expression fills in for me when I choose the variable supplied by the auto weather plugin. How do I create a matches regex?

I really wish I understood all the stuff better, sorry for asking these questions that probably seem pretty straight forward to you guys, I do attempt to search all this stuff out before I ask on forums. I'm porting projects over from tasker and soon it will be all done then ill share some nice flows with everyone.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Regex and matches, expressions.

Post by Martin » 24 Sep 2015 18:49

Hi,

You could also use function contains(weather, "cloud") or contains(toLowerCase(weather), "cloud") in a condition Expression to execute different actions in the flow.
A regular expression could look like this: matches(weather, '(?i).*cloud.*') (note that the i to switch the regex to case insensitive mode needs to be written in lower case).

Regards,
Martin

dragon
Posts: 29
Joined: 10 Sep 2015 08:13

Re: Regex and matches, expressions.

Post by dragon » 26 Sep 2015 23:32

Thanks again Martin!

Post Reply