Hi, I would like to filter notifications by checking if a notification title contains a certain word.
I know that by using the following in an expression, I can check whether the WHOLE title is the word itself:
title == "notificationtitle"
I would like to know how to check if a notification title even just PARTLY matches the word im looking for. I was thinking I have to add something between the quotes, but i wouldn't know what. (Im new to automagic)
How do I do this?
Check wether notification contains certain word (s)
Moderator: Martin
Re: Check wether notification contains certain word (s)
Hi,
You can use a function in a condition Expression to check if a variable contains the text 'xyz':
indexOf(variable, "xyz")!=-1;
or if a variable starts/ends with xyz:
startsWith(variable, "xyz");
endsWith(variable, "xyz");
or more flexible with a regular expression:
matches(variable, ".*xyz.*");
All available functions are listed in the help page of action Script (scroll down to section Functions):
http://automagic4android.com/en/help/co ... ion_script
Regards,
Martin
You can use a function in a condition Expression to check if a variable contains the text 'xyz':
indexOf(variable, "xyz")!=-1;
or if a variable starts/ends with xyz:
startsWith(variable, "xyz");
endsWith(variable, "xyz");
or more flexible with a regular expression:
matches(variable, ".*xyz.*");
All available functions are listed in the help page of action Script (scroll down to section Functions):
http://automagic4android.com/en/help/co ... ion_script
Regards,
Martin
Re: Check wether notification contains certain word (s)
Hey Martin,
I had already written a code that checks the contents of a string, reading character by character to see if it contains the sequence of characters that I'm looking for (I guess the same method that the functions use to get the job done). It works, but using indexOf() is way easier!
Thanks!
I had already written a code that checks the contents of a string, reading character by character to see if it contains the sequence of characters that I'm looking for (I guess the same method that the functions use to get the job done). It works, but using indexOf() is way easier!
Thanks!