Hi All,
Can we use RegEx command for reading & matching for multiple lines?
Like:
The lines are:
{ I am a Boy.
Who r u?
....}
O/p:
"I am a Boy.
Who r u?
...."
In Perl we can use =~ s/pattern/substitute/sg
i.e. we can we use "s" at the end to tell to read for multiple lines.
Can we do the same using RegEx?
Can we do a pattern matching for multiple lines using RegEx?
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 63
- Joined: Thu Dec 10, 2009 8:13 am
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I may not quite understand what you want to do - Macro Scheduler's RegEx reads across multiple lines without the need to add anything to the pattern.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 63
- Joined: Thu Dec 10, 2009 8:13 am
Sorry
Sorry, my pattern was wrong ....! I forgot that comma ',' may create prob in pattern in RegEx..
Hi Niroj@Work,
You wanted to use a RegEx> command to turn this:
The above throws an error because the { and } characters are special as they are used to define complex expressions... so we can't use them this way in a Let> command. The way around this problem has traditionally been to use variables, see below.
Example 2 throws two errors but produces correct output anyway - possible bug?
Marcus, please try to reproduce. Are these error msgs bugs or are they justified? I tested in MS version 11.1.23 on XP SP3.
Finally, I found a way that works and does not throw errors using the ConCat> command, see below:
Example 3 throws no errors
Thanks for posting this question Niroj@Work and take care.
You wanted to use a RegEx> command to turn this:
Into this...Input lines wrote:{ I am a Boy.
Who r u?
....}
Example 1 throws an error and does not run - fair enoughOutput lines wrote:"I am a Boy.
Who r u?
...."
Code: Select all
Let>input={ I am a Boy.%CRLF%Who r u?%CRLF%....}
MDL>input
Let>pattern={|}
RegEx>pattern,input,0,matches,num,1,",output
MDL>output
Example 2 throws two errors but produces correct output anyway - possible bug?
Code: Select all
Let>left_brace={
Let>right_brace=}
Let>input=%left_brace% I am a Boy.%CRLF%Who r u?%CRLF%....%right_brace%
MDL>input
Let>pattern=%left_brace%|%right_brace%
RegEx>pattern,input,0,matches,num,1,",output
MDL>output
Finally, I found a way that works and does not throw errors using the ConCat> command, see below:
Example 3 throws no errors
Code: Select all
Let>left_brace={
Let>right_brace=}
Let>input=%left_brace%
ConCat>input, I am a Boy.%CRLF%Who r u?%CRLF%....
ConCat>input,%right_brace%
MDL>input
Let>pattern=%left_brace%
ConCat>pattern,|
ConCat>pattern,%right_brace%
RegEx>pattern,input,0,matches,num,1,",output
MDL>output
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Or:
Let>input={"{ I am a Boy." + %CRLF% + "Who r u?" + %CRLF% + "....}"}
MDL>input
Let>pattern={"{|}"}
RegEx>pattern,input,0,matches,num,1,",output
MDL>output
Let>input={"{ I am a Boy." + %CRLF% + "Who r u?" + %CRLF% + "....}"}
MDL>input
Let>pattern={"{|}"}
RegEx>pattern,input,0,matches,num,1,",output
MDL>output
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?