Hey everyone, I’m trying to refine an automation that filters calendar events based on specific criteria, and I could use some help tweaking the regex expression. Here’s what I’m aiming for:
- If an event starts with the letter ‘T’, it should return false.
- If there are 3 or 4 consecutive digits anywhere in the event title, it should return true.
For example:
- “T7575” should return false (starts with ‘T’).
- “ABC 867 ZXY” should return true (contains ‘867’).
- “Pickup” should return false.
- “Some words (55:76)” should return false (only 2 consecutive digits).
- “YGF AB658 YHJ” should return true (contains ‘658’).
- “YGF 6658 YHJ” should return true (contains ‘6658’).
Here’s the regex expression I’ve come up with so far:
regex
^(?!T).\b\d{3,4}\b.
It works for cases like “ABC 123 XYZ” but fails when there are letters immediately next to the numbers, such as in “ABC DE875 XZY”. The expression returns false in this case, but it should return true.
I’d appreciate any suggestions on how to adjust the regex to handle these scenarios correctly. Thanks in advance for your help!