RegEx for Horizontal Whitespace (\s \h \t blank etc)

Maybe it isn’t Unicode-capable. Or he has copied the reference list from the ASCII column on regular-expression.info or so.

What does happen when you use \h ?

Oh it supports \h just fine:

It just doesn't list it in the app's reference sheet.

1 Like

While we're on this subject, here's another macOS app, Expressions (I remembered this one from my Setapp trial) that both handles [[:blank:]] appropriately and correctly explains what `\h' does:

Yes, this one looks nice. But — unless I’m missing something — it is impossible to set the flags per expression. (Only globally in the prefs.) Not good.

Hmm. Unless I'm missing something (very possible, since my regex expertise and experience is still quite low) it looks like you can set per-expression flags with the standard `(?[FLAG]) and (?-[END FLAG]) syntax:

(both of these tests were done with case sensitivity turned ON in the global preferences)

Ah, ok, great. (I only tried the /pattern/flag syntax.)

Thanks

1 Like

Outstanding test tool, Tom! :+1:

That really answers the question for KM:
\h and [[:blank:]] ARE equivalent!

I’m still irritated by all the references/documentation that failed to provide adequate details for [[:blank:]]

But the important thing is we now know for sure, at least for KM.

For me, I’ll just continue to use \h in KM.

Good catch Tom! I must remember to always make that setting.
Hopefully there is a way to do so in the web app settings/preferences.

Was that added in the BBEdit Ver 12 upgrade?
I’m not seeing it in BBEdit 11.6.8 (397082) on macOS 10.11.6.

Yup, it’s new to version 12. That and auto-surround for brackets, parentheses, and other delimiters fix a couple of quibbles I’ve had with BBEdit almost since I started using it.

2 Likes

Yep, just upgraded and found it.

I was able to take @Tom’s test case and run it through BBEdit 12 – confirmed.

One thing I immediately missed in the Live Search: It doesn’t provide a dropdown of recent searches. I find that very valuable in the main Find window.

1 Like

True, that would be a good addition, especially since they already include the drop-down for saved grep patterns. Here’s hoping they add it in a future point release.

1 Like

Thanks again Tom for point that out.

I use RegEx101.com a lot -- it is my main RegEx testing tool, as well as my RegEx snippet manager.

If anyone else uses it a lot, you may be interested in this short macro to set the Unicode Flag.

  • It does NOT do any error checking, and
  • you MUST already have the RegEx101.com site open, in the main window.
  • It should work in either Safari or Chrome, but I have tested it only in Chrome.

###MACRO:   Set RegEx101 Unicode Option

~~~ VER: 1.0    2017-10-14 ~~~

####DOWNLOAD:
Set RegEx101 Unicode Option.kmmacros (3.5 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


If you have any issues or suggestions, please post here.

1 Like

Wiki Update -- RegEx ICU 55 Metacharacters

To everyone who participated in this discussion, please take a look at this wiki update and give us you comments in the above topic.

I don’t know, this thread popped up in my mail notifications, but it is as simple as this:

Horizontal Space: \h
Any Newline character (including CRLF sequence): \R

This is for KM (using ICU regex)

If you are running macOS Yosemite or older this may not work.

[Edited by moderator: 2018-07-13 16:28 GMT-5] to correct \R]

Yes, as described in the ICU 55 stuff, \h and \R work only in macOS 10.11+, a fact I found out the very hard way since Keyboard Maestro 8.x still supports 10.10.

Nyet.

\R == Match a new line character, or the sequence CR LF.

**The new line characters are \u000a, \u000b, \u000c, \u000d, \u0085, \u2028, \u2029 [Since ICU 55]

\s == Match any space.

-Chris

3 Likes

Yes, thanks for the correction!

(Probably I meant that \h combined with \R matches any space, but you are right, we have \s for that.)