Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Regex not working
-
I'm trying to filter out lines that contain a date string so I can present them as a list.
The lines that I am looking for are formatted as "
YYYY-MM-DD — Sometext
". When I filter lines for the exact date string it works fine. However, I have varying dates, obviously, so I came up with this simple RegEx "\d{4}.\d{2}.\d{2}...
". Now nothing gets found. In fact, not even\d
finds anything.What am I doing wrong? All the online RegEx testers I've tried say that my syntax is correct.
-
When you filter lines with a regex, the pattern has to match the entire line, not just a part of it. Try a pattern like
\d{4}-\d{2}-\d{2}.*
(the.*
should match anything that comes after the date). -
Thanks Ole. Works perfectly now. A hint in the manual would be nice.
-
Any chance we'll one day be able to use start/end of line anchors in our regexes for the Filter Lines action? Seems a pretty big oversight.
-
Agreed on adding a hint to the help. Also, this isn't the way regexes seem to work in other actions that accept regexes. Would be nice to have consistency here. It also forces me to have more complex regexes than I really need. For example: I'm filtering on multimarkdown metadata in a workflow I'm making to post to my blog. If Title: is present at the beginning of the line I should be able to filter that line with just "^Title:". As it stands right now I have to use the slightly more complicated "^Title:.*". In this case it's not really a big deal but I'd prefer the shortest regexes possible ;)