RegEx: Global and Wiki


Some questions regarding RegEx:

1. How do I specify a global expression, like \d+/g, as used on the "/g" doesn't work in the Search Variable action. (see below)

2. A search of the wiki for "RegEx" finds nothing.

  • I have noticed that you spell it out everywhere.
  • In my many searches on the 'net, it seems most people use "RegEx".
  • Can we use this in the wiki?
  • Or is there a synonym list that would allow the user to search for "RegEx" and the search engine uses "Regular Expression"?
  • Otherwise I fear that some (many?) users will not find any info on RegEx.

3. What language does KM use for RegEx?

  • For example, PCRE, JS, PY, other?
  • We need to document this in the wiki



Here's my test RegEx macro::

We don’t need to document it on the wiki, it is perfectly well documented in the Help menu which leads to:

ICU Regular Expression Reference

Which answers all of your questions:

  • What flavor of RegEx? ICU.
  • How do you get greedy? All regex modifiers are greedy by default.
  • So how do you get non-greedy? Add a ?. Eg, “a.*?b”.
  • Can we use “RegEx” on the wiki? No, I don’t generally abbreviate things in formal documentation. Here is fine, use whatever you like, even RE on occasion is sufficient. Same for using “KM” for Keyboard Maestro.
  • Maybe there would be sense in duplicating the Glossary from the documentation on the wiki (probably not, but maybe), or add the term RegEx to the Glossary (probably).

You can see that the pattern match is greedy because the \d+ matches all three numbers “123”. If it was not greedy, it would match only 1.

You are talking about “global” not greedy. You cannot match globally in a Search Variable action - where would you put all the matches? If you want to match multiple times (globally), we all know what action to use whenever there are multiple things, right? The For Each action. Then you can iterate over all the RegEx matches using the Substrings In collection.

I never even thought to look in the Help menu. Since the Action help now takes us directly to the wiki, I think a reasonable expectation is that the wiki should be comprehensive. Am I wrong in thinking this?

Seems like a link to it should be on the major RegEx wiki pages.
I did search the wiki for every form of regular expressions, and it did not return "ICU Regular Expressions Reference"

This reference says:

The regular expression patterns and behavior are based on Perl's regular expressions.

This is the information we need we comparing with other sources on the Internet, and other RegEx tools.

ICU Regular Expressions are very similar to PCRE, but not identical. They are missing:

  • Recursion
  • Conditionals
  • Named Captures
  • Embedded Code

Yes, the wiki is not comprehensive. Neither is the documentation.

And there is no well defined devision either.

Perhaps I should abandon the documentation altogether and just put everything on the wiki, but that is not the current state. The wiki also has the disadvantage of not being per-version, so either every page has to have tags to say what changed when, or anyone using the old version just has to guess (which is a bit the way its going to end up anyway).

I like that. I very much like having only one place to search.

Carrying two versions in the wiki is complicated, and a PITA, I get that. :smile:
I wonder if this makes sense: If a page needs changing due to Ver 7, what if you copy the page, and mark each with their ver, and a link to the other page?

OR maybe you just direct all KM6 users to the standard documentation, and make the wiki pure KM7?

Hey Guys,

I like having a searchable PDF locally.

I also like to be able to put PDF documentation on my iPad, so I can read up on things when I'm off doing the hurry-up-and-wait routine somewhere.

I do believe there needs to be a page on regular expressions on the wiki. It need not be long or comprehensive, but it should briefly define what a regex is and provide a link to the ICU docs.

The damned search in the Help menu does not find things in the Help menu.

Long ago I searched for regular and regex in the Help menu's search field and didn't find it. I wrongly concluded it was't in the KM menu system, and Peter later corrected me.

That's how I learned of the Help menu's limitation.

Many people never read the titles in the help menu — sad to say.

Many people don't know you can search for menu items.

Peter — how about putting another separator in there to emphasize the ICU date and ICU Regex sections?


The problem is how to you keep the PDF up to date?

Seems to me for that to work, you would need an on-demand, wiki to PDF generator.

It is hard enough to maintain documentation in one place, much less 2 or 3.
And, as all good DB admins know, as soon as you have data in two places one of them will be wrong, or out of date. :smile:

Chris, can't your iPad talk to the Internet? LOL

At the moment Peter prints the online help file to PDF (available from the help page). Its links are not brought into the PDF unfortunately, but it's searchable.

I'm not always in places with WIFI.   :wink:


That was a joke! LOL

That is true, but more and more of the documentation is moving to the wiki, which is making the actual documentation less complete, but the overall documentation more complete.

I have not yet concluded where this trend will end, but the removal of Actions, Tokens, Conditions, Collections, Functions has already reduced the documentation PDF significantly (about 20%).

[quote=“peternlewis, post:10, topic:1858”]more and more of the documentation is moving to the wiki, which is making the actual documentation less complete, but the overall documentation more complete.

Hey Peter,

The search on the wiki is pretty impressive — much better than in the KM help-viewer or the docs on the web — so one of my big reasons for wanting a PDF has gone away.


1 Like

The most serious problem I’ve found on the wiki search is it does not handle equivalence of plurals. So search for “shortcut” and “shortcuts” find completely different results.

Hey Peter,

Agh! That's very pesky.

I assume the wiki software authors have been lobbied to fix this...

I'd probably look at the most relevant equivalences and put them in as text-tags — unless there's a cleaner solution.


I'm not sure. I asked on the dokuwiki forum and received deafening silence so far.

Most things in dokuwiki can be affected by plugins, but I didn't find any specific plugin to resolve this.

Is there a plugin for synonyms?