Smart rule case sensitive regex

hi there,

i am having a problem with case sensitive regex in my smart rules. this is the rule:
Scan text - regex - IE([0-9A-Z]*).
I output \1 with display alert

i would have expected to match on IE00BK5BQT80 but it matches on Wien instead. it should neither match on ie nor on the n since it isn’t in the regex.

Content is literally just Wien is a test

what am i doing wrong here? How could i enforce case sensitivity? Thanks a bunch.

CleanShot 2021-02-14 at 23.37.55

You can use (?i) at the beginning for case-insensitive matches but I think there’s a bug here.

@BLUEFROG it seems to be case insensitive already.
unfortunately (-?)IE([0-9A-Z]*) does not match THIS IENSDF

That’s correct and intentional (and consistent to searching in databases).

had a typo above (?-i) works it seems.

not sure i agree with you as with a regex you can very explicitely search for things. [A-Z] vs [a-z]

We might add an option to future releases.

1 Like

May I suggest to simply stick to what is common practice with REs? I.e. respect case-sensitivity unless the i flag is specified. Everything else is… unexpected. Although database search is case-insensitive, it does not permit REs anyway, so one does not really need alignment in this respect. My opinion, of course.

2 Likes

What is the current functionality regarding regular expressions in smart rules?
It seems that the current version 3.9.9 of DT doesn’t consider the modifier (?-i), meaning it doesn’t support case-sensitive matching.
I have the impression that DT doesn’t consider the regexp in the Scan Text action at all. In any case, the smart rule returns all records in the search range, regardless of whether I use (?-i)(\bGHT\b), (?-i)(GHT), or simply (GHT) as the regular expression. Or what am I doing wrong?


(See also "Case Sensitive" option in Search - #8 by BLUEFROG)

On the other hand, a Spotlight search for “GHT” apparently returns all hits available in DT! And I’ve always wondered why Spotlight should index the documents archived in DT!

That’s not the correct syntax. ICU regex is (?i) for case-insensitivity. Case is considered by default, which is pretty much standard behavior in regex.

Are your documents in a group that has been excluded from search in the Generic info inspector?
Select the parent group and press Command-Shift-I to open the Generic info popover.

On the other hand, a Spotlight search for “GHT” apparently returns all hits available in DT! And I’ve always wondered why Spotlight should index the documents archived in DT!

Spotlight is optional and will work per-database if File > Database Properties > Create Spotlight Index is enabled.

Yes, but I need case-sensitivity, so it should be (?-i), no?

You should omit it completely. You only use it when case doesn’t matter, e.g., ght and GHT and ghT could all be matches.

How can I tell if the Scan Text action was successful?
If I manually apply the following smart rule, then the documents that match the RegEx condition should be tagged with ‘GHT’, right? But no document was tagged during the action.


(No documents have been excluded from search.)
I’ll be back tomorrow.

The Scan Name/Text action is not case sensitive currently.

Thank you.