Does anyone know where I can find the docs describing Regex parsing capabilities of macOS search fields?
What I mean, I'd like to read about the regex syntax rules that are allowed and parsed by the search field. For example, what I didn't know until today that, in macOS Preview (or any other application with a standard search field, guessing) we can use input like this:
"\s" AND "an" AND "\s"
This works and hints that search fields interpret more regex then we know, and this is what I want to read/find out about. The example above searches for "an" with one trailing and leading whitespace character \s
within a opened document.
I'd like to know more about those grouping rules and regex characters wrapping/escaping so it can be correctly parsed. Also does this format of input apply to systemwide search fields of any application?
I can't find any docs describing these features and was found only this on developer.apple.com library instead.
Below you can see an example of default search behaviour for a "an" word within a PDF document, it shows all "an" occurences in the results, regardless if you put a space before the "an" word, so your input is " an "
When we put "\s" AND "an" AND "\s"
into the search field we get the more desired search result
This makes a huge difference for searches containing common words!
In short: I'd like to know more about the functionality you see above. Where can I find any (official) documentation about it?
The answers provided (so far) are not answering my question, thank you for them though - aggregating more related information is good.
"\s" AND "an" AND "\s"
above is incorrect. At least in my version of Preview (macOS 10.15),"\s" AND "an" AND "\s"
and simply searching"an"
(with quotes) give the exact same result with respect to finding the word "an" (surrounded by spaces). What including"AND \s"
does is to add the additional requirement that an "S" (again with leading and trailing spaces) should also be present somewhere in the document, but without any restriction as to where. The backslash ("\") appears to be ignored completely.