Need help with regex / Notification on Statusbar

Post your questions and help other users.

Moderator: Martin

Post Reply
chiph
Posts: 3
Joined: 24 Mar 2015 21:40

Need help with regex / Notification on Statusbar

Post by chiph » 06 Sep 2017 19:57

I am trying to set up a new trigger for Notification on Statusbar Displayed, matching on Text. I am able to get it to match on 'contains text' but not matches regex. I have tested the regex, and am able to fully match the string. I'm sure I'm just entering it incorrectly (I'm just putting the regex on the line). The goal is to alert me when an email comes in with a fairly specific subject. The text I am trying to match is:

Urgent Ticket Notification (xxxxx - Open)

Where xxxxx = some integer. For example,

Urgent Ticket Notification (17001 - Open)

The regex I am using is:

^Urgent\sTicket\sNotification\s\(\d+\s-\sOpen\)

I am matching the beginning of the line because I don't want to get a match if someone forwards me the email, for example:

FW: Urgent Ticket Notification (xxxxx - Open)

Can someone tell me what I'm doing wrong and/or if there's a better regex I can use?

Thanks!

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

Re: Need help with regex / Notification on Statusbar

Post by Martin » 06 Sep 2017 20:10

Hi,

You can use action Scripts regular expression tester to see if your regular expression matches the text. Just create an empty action Script somewhere in a flow and press the Regular Expression Tester-button.
The text in the notification might contain some unexpected newlines or even some additional text so I recommend to use a condition Debug Dialog to see if the regular expression has to be extended in some way.
Maybe you have to enable DOTALL mode (single line mode) with (?s) in front of the pattern to let . also match newline characters.

Regards,
Martin

chiph
Posts: 3
Joined: 24 Mar 2015 21:40

Re: Need help with regex / Notification on Statusbar

Post by chiph » 07 Sep 2017 13:33

Thanks Martin - that Debug Dialog was exactly what I needed. The regex tester was giving me a match, but it turns out that there's a lot more inside the notification than I had realized. I've got a lot to go on now. I appreciate it!

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: Need help with regex / Notification on Statusbar

Post by Bluscre » 07 Sep 2017 14:09

You could also use glob ^^

Code: Select all

Urgent Ticket Notification (? - Open)*
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

chiph
Posts: 3
Joined: 24 Mar 2015 21:40

Re: Need help with regex / Notification on Statusbar

Post by chiph » 13 Sep 2017 19:13

Bluscre wrote:You could also use glob ^^

Code: Select all

Urgent Ticket Notification (? - Open)*

Thank you!!! That did the trick!

Post Reply