Page 1 of 1

REGEX (matches) not working in long strings (?)

Posted: 15 Aug 2016 12:03
by Prohr
Hello,

I want to make the phone silent whenever the calendar has an entry. However this should not happen if the calendar entry has the word "home" in the title or if the calendar entry has the word "Reise" in the description. The first part (home office, Homeoffice, etc) is working well. However for some reason, the word "Reise" in the description is not recognized [ matches (event_description , ".*Reise.*") ]. What am I doing wrong?

Below is an excerpt from the log, where you can see that the description does indeed contain the word "Reise" but the expression leads to "false".

...
{event_calendar=Kalender,event_availability=BUSY,event_start=1471196340000,event_description=Reise: Zürich HB nach Winterthur
Datum: 14.08.2016
-
Ab 19:37 Zürich HB - Gl. 14 (IR 2133, Richtu...
,account_type=AquaMail (Exchange),event_location=Zürich HB,event_title=Zürich HB - Winterthur,triggertime=1471196340004,event_all_day=false,flow_name=Kalender Eintrag Beginn,event_id=272,trigger=Kalender Event: Kalender: AquaMail (Exchange):Kalender Normaler Event Beschäftigt (genau bei Beg...,event_end=1471197900000}}
14.08.2016 19:39:00.008 [Kalender Eintrag Beginn]
Start executing condition 'Expression: matches (toLowerCase(event_title) , ".*home.*") OR matches (event_description , ".*Reise.*")'
14.08.2016 19:39:00.009 [Kalender Eintrag Beginn]
Start executing action 'Benachrichtigung auf Bildschirm: {matches (toLowerCase(event_description) , ".*reise.*")} (lange)'
14.08.2016 19:39:00.263 [Kalender Eintrag Beginn]
End executing condition 'Expression: matches (toLowerCase(event_title) , ".*home.*") OR matches (event_description , ".*Reise.*")' with return value false
...

The calendar event is imported from the timetable of Swiss Railway (SBB). My phone is running on Android 6.0.1.
Any hint will be much apreciated!

REGEX (matches) not working in long strings (?)

Posted: 16 Aug 2016 05:53
by Prohr
I got it to work when I shorted the string event_description with the function left(event_description, 30). I was not aware that "matches" is only working on short strings. Is this by design?
Anyhow, I am glad it works now... :-)

Re: REGEX (matches) not working in long strings (?)

Posted: 21 Aug 2016 13:27
by Martin
Hi,

The string length should not be an issue since the matches-function does not impose any artificial limits (except total available memory).
Maybe your string contains a newline character. You can turn on DOTALL mode by prepending (?s) to ensure that a dot also matches newline characters, for example: matches(event_description , "(?s).*Reise.*")
Also check the regular-expression tester available in action Script. Documentation of the flags like m, s, i are available in the help page in the regex-tester at the bottom o the page.

Regards,
Martin