REGEX a simple example on how to use REGEX for validation in KM

Part 1: Test macro

This is a very simple macro to show to call and use REGEX in Keyboard Maestro.

You can change the trigger and the actual REGEX expression as required.

Hopefully, it will help you overcome the "fear" of using REGEX when appropriate, I know I have put it off for a long time.

===================================
Pics of Macro

REGEX a simple example on how to use REGEX ifor validation in KM Part 1

REGEX a simple example on how to use REGEX ifor validation in KM Part 2

REGEX a simple example on how to use REGEX ifor validation in KM Part 3

===================================
Part 2: Learning REGEX

RegexOne Learn Regular Expressions with simple, interactive exercises. (cited by Peter_Sanders)

Regular expressions are extremely useful in extracting information from text such as code, log files, spreadsheets, or even documents. And while there is a lot of theory behind formal languages, the following lessons and examples will explore the more practical uses of regular expressions so that you can use them as quickly as possible.

https://regexr.com/ Validation tool (cited by Mark)
https://regex101.com/ Validation tool for Regex expressions (cited by JMichaelTx)

https://www.regular-expressions.info/tutorial.html Excellent reference site (cited by Tom and JMichaelTx)

https://www.regexbuddy.com/democreate.html This ONLY runs on windows, but helps you build the REGEX expression you want, so if you have access to a Windows PC, it is worth considering.

===================================
Part 3:

More info and You should use the RegEx flavor pcre (php) in RegEx101.com 12, since this flavor is the closest match to what KM uses: ICU Regular Expressions 1.
• You set the RegEx flavor in RegEx101.com 12 in the settings pop-out Sidebar: etc (cited by JMichaelTx : Open RegEx101.com, Login, Set Flags )

Using RegEx to Parse the KM Engine Error Log 4
Generally the tool you use, like Keyboard Maestro, JavaScript, BBEdit, TextWrangler, etc, will provide specific methods for obtaining a match, and then doing something with that match.
See Regular Expressions [Keyboard Maestro Wiki]

To paraphrase PeterNLewis: Keyboard Maestro is like lego, so you achieve what you want by a series of small steps, hence I would use Keyboard Maestro to make my input uppercase rather than do it on REGEX

For some more background , some examples



Sum up all numbers matched by RegEx pattern (citation CCStone and GGlick)
Regex Parse Pipe Character
Extracting text from clipboard and doing something with it for all the tags (citation GGlick)
Regex ^ and $ matching fine in regex101.com but whopping it up in kbm (citation JMichaelTx)
Using the Regex101.com Regular Expressions Tool (citation JMichaelTx)[REGEX] a simple example on how to use REGEX for validation in KM..kmmacros (14.8 KB)

===================================

[REGEX] a simple example on how to use REGEX for validation in KM..kmmacros (14.8 KB)