Is it possible to apply filter based on a regular expression? What I had in mind was something like
(filter #"<+\p{Alnum}+>" ["abc" "<def>"])
to return
=> ["<def>"]
Thanks in advance for hints.
You can repeat expressions with an asterisk or plus sign. A regular expression followed by an asterisk ( * ) matches zero or more occurrences of the regular expression. If there is any choice, the first matching string in a line is used.
$ means "Match the end of the string" (the position after the last character in the string). Both are called anchors and ensure that the entire string is matched instead of just a substring.
Regex is not on the list of search features, and it was on (more or less, as Better message search functionality (i.e. Wildcard and partial word search)) the list of pre-canned feature requests, so the answer is "you cannot do this via the Gmail web UI" :-( There are no current Labs features which offer this.
Most characters, including all letters ( a-z and A-Z ) and digits ( 0-9 ), match itself. For example, the regex x matches substring "x" ; z matches "z" ; and 9 matches "9" . Non-alphanumeric characters without special meaning in regex also matches itself. For example, = matches "=" ; @ matches "@" .
Put your regex inside an anonymous function that tests matching to your regex. The general form would be:
(filter #(re-matches REGEX %) SEQUENCE)
Where REGEX is the regex that you're interested in, and SEQUENCE is the sequence that you're interested in. Trying your example,
user> (filter #(re-matches #"<+\p{Alnum}+>" %) ["abc" "<def>"])
("<def>")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With