Hello,
is it possible using a regular expression in an smart rule to find multiple occurrences of a string in a document and then use this result to change the document’s name (by adding the multiple occurrences)?
For example, the regular expression
/hello/g
looks for multiple occurrences of the string “hello” in a document (I basically use Regex101.com to check). However, it seems as if Devonthink would not allow me to prefix a
/
and suffix
/g
in a regular expression being placed in a smart rule. Is this the case?
This being said in general, I am looking for a way to solve this particular scenario:
I want to read in receipts from DHL the tracking numbers they contain. For example, in a document there are the tracking numbers “RM661929878DE” and “LP042481351DE”. The numbers are basically readable (cross-checked with a plain text conversion) and Regex101.com says that the regular expression
/((RM|LP|RC)[0-9]{9}DE)/g
retrieves both numbers.
When I put this checked expression in a smart rule (as action under “scan text” and “regular expression”), the “display alert” function I also set up doesn’t even appear (and doesn’t return anything).
On the other hand, the expression
((RM|LP|RC)[0-9]{9}DE)
– so without global mode
/
…/g
– returns only the first tracking number (“RM…”), but not the second one (“LP…”).
What else could I try?