RegEx Help

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 421
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

RegEx Help

Post by PepsiHog » Thu Nov 14, 2019 7:31 pm

Hello Everyone,

I recently download RegExBuddy. Great software. I was working on a pattern that I just couldn't quite get. With in 30 minutes of using RegExBuddy, I figured it out. Atleast, as far as REbuddy is concerned.

But when I use the same pattern in MS, it doesn't work.

Code: Select all


ReadFile>E:\Felix's Movie Control\Active Pages\CenterPages.txt,nFile


//RegEx>(/\*)\s\w+:\s((.*\s){12}),nFile,0,match,nom,0

// This Pattern works in RegExBuddy.
RegEx>(/\*)\s\w+:\s(.*\s){9}(\*/),nFile,0,match,nom,0

//RegEx>^(/\*)\s,nFile,0,match,nom,0

//(/\*)\s\w+:\s((?:.*\s){10})
//(/\*)\s\w+:\s(.*\s){9}(\*/)


/*
Page99_Datab:
" INDEX","        Movie Name"," Year"," No Cinavia","  Audio","Playable","   Like"
"   AAA","Good Morning","(1991)"," 1111111","","",""
Index,"p99 Zorro The Gay Blade p99","(1981)"," "," "," "," "
,,,,,,a
,,,,,,b
,,,,,,c
,,,,,,d
,,,,,,e
,,,,,,f
*/


/*
Page1_Data:
" INDEX","        Movie Name"," Year"," No Cinavia","  Audio","Playable","   Like"
"   AAA","Good Morning","(1991)"," 1111111","","",""
Index,"p1 Zorro The Gay Blade p1","(1981)"," "," "," "," "
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
*/


/*
Page2_Data:
" INDEX","        Movie Name"," Year"," No Cinavia","  Audio","Playable","   Like"
"   AAA","Good Morning","(1991)"," 1111111","","",""
Index,"p2 Zorro The Gay Blade p2","(1981)"," "," "," "," "
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
*/


/*
Page3_Data:
" INDEX","        Movie Name"," Year"," No Cinavia","  Audio","Playable","   Like"
"   AAA","Good Morning","(1991)"," 1111111","","",""
Index,"p3 Zorro The Gay Blade p3","(1981)"," "," "," "," "
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
*/

The code blocks are what the macro gets when it reads the file(all four). I am trying to get four results.

Can anyone show me the *magic*?

Marcus says that regex in MS is "PCRE" version.

Thanks in advance,
PepsiHog
MS v14 Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2019) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Grovkillen
Automation Wizard
Posts: 368
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: RegEx Help

Post by Grovkillen » Fri Nov 15, 2019 12:19 am

You should use the a specific regex "flavor"... Can't remember the exact name right now though.
Let>ME=%Script%

Running: MS14.5.4

User avatar
PepsiHog
Automation Wizard
Posts: 421
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: RegEx Help

Post by PepsiHog » Thu Nov 21, 2019 1:13 am

@ Grovkillen,

Now how is that helpful, huh? Next time we go to tribal counsel, I am voting you off the island!

PepsiHog
MS v14 Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2019) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

hagchr
Macro Veteran
Posts: 269
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: RegEx Help

Post by hagchr » Sun Nov 24, 2019 7:32 pm

Hello,

I have read that MS uses a version (not the latest) of Perl but am not sure about the details.

To get blocks incl tokens you can eg use:
(?s)/\*.+?\*/

To get blocks w/o tokens you can eg use:
/\*\R\K(?s).+?(?=\R\*/)

where
(?s) turns on single line mode
\R matches end of lines
\K discards what has been matched up until that point

I note you use a couple of (). That can be good if you need to reference back to contents within () later, if not it will consume unnecessary memory. Sometimes not a problem, but for larger problems, if you need the () just to keep it organized you can add a ?: in the beginning of the () to declare that it should not be memorized eg (?:pattern).

User avatar
PepsiHog
Automation Wizard
Posts: 421
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: RegEx Help

Post by PepsiHog » Mon Nov 25, 2019 9:29 pm

@ hagchr,

Thanks. Works well, and I learned something today. Now what to do the rest of the day?......... :lol:

PepsiHog
MS v14 Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2019) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply