Isak
June 20, 2017, 2:22pm
#1
Hi i´m trying to wrap my head around RegEx for finding mail adresses in huge blocks of texts. But I´m not able to find a functional RegEX to copy from regex101.com . And when i did find one, it worked, but only saves one email adress. not multiple..
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,}\b
Any help is greatly appreciated!
Put the RegEx in a For Each action (KM Wiki) , and add the For Each variable to another collection variable.
Similar to this:
Isak
June 21, 2017, 12:02pm
#3
Thank you @JMichaelTX !
I´m getting closer, but whats the function for the first action "Set Variable to text" Do I keep it empty?
Still not getting the results i want here..
Uploading my macro and sample text, containing two mail adresses that should be captured here.
""
I would like my macro to capture the email adresses test@test.com , and freddy@test.no, but not get anything else out. ""
Search for email adresses.kmmacros (3.9 KB)
Tom
June 21, 2017, 5:19pm
#4
If you use a regex in a For…Each action than it is always case sensitive. Hence, the A-Z
character range will only get uppercase letters. You have to add a-z
.
Try this:
Search for email adresses [mod].kmmacros (3.4 KB)
It is to reset the FEW_Results variable. Otherwise the variable would accumulate the results with every macro run. So, leave it empty, yes.
You can disable the action to see what I mean.
@Isak :
That is the default , which can be overridden by using the
(?i)
option at the beginning of the expression, as in:
For more info about this and other RegEx options,
see Regular Expressions (KM Wiki) .
Also, you may want to review the email RegEx patterns here:
Email Address Regular Expression That 99.99% Works.
Isak
June 22, 2017, 8:27am
#6
Thanks @Tom and @JMichaelTX !
Very helpful!