Anybody know the syntax that DEVONthink uses for regex capture groups greater than 9? I can’t seem to figure it out.
That isn’t supported. Do you have an example of what you’re parsing and why you’d need that many capture groups?
AFAIK, DT uses the ICU regular expressions, and those know about "named capturing groups.
Eg
(?<year>\d{4})-(?<month>\d\d)-(?<day>\d\d)
applied to “2025-07-14”
should make the matches available as \k<year>, \k<month>, and \k<day>
That doesn’t seem to work in DT. However, Apple’s Foundation framework has supported named capturing groups for some time.
I whipped up a short JavaScript/ObjC example illustrating the usage of named capturing groups. It uses three of those to match a yyyymmdd date in a string and outputs the date as dd.mm.yyyy at the end.
I didn’t bother with comments, since the point was merely to illustrate that everything is in place for named capturing groups. So it might be just a matter of time until DT supports them, too ![]()
(() => {
const string = 'Scan_20251207_124226_000223';
const regEx = $.NSRegularExpression.regularExpressionWithPatternOptionsError('(?<year>\\d{4})(?<month>\\d\\d)(?<day>\\d\\d)', $([]), Ref());
const firstMatch = regEx.firstMatchInStringOptionsRange($(string), $([]), $.NSMakeRange(0, string.length));
const dateValue = ['day', 'month', 'year'].map(v => {
const range = firstMatch.rangeWithName($(v));
return $(string).substringWithRange(range).js;
}).join('-');
console.log(dateValue);
})()
The output of this script is 07.12.2025.
I work with PDF’s that have different groupings of text and numbers. However, they’re not always preceeded and succeeded by the same words but they are always the same number of digits or combination of letters and digits so the best way to search is by regular expression. I have a renaming format that I use but it requires a regex using 11 capture groups. I’m sure there is a simpler way, but I’m new to regular expressions and this is the only way i’ve gotten it to work so far. But I can’t use any capture group >9
Posting example text and the naming convention that requires 11 capture groups would be helpful.