Getting Error While doing Regular Pattern Matching--- Trim

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Niroj@Work
Pro Scripter
Posts: 63
Joined: Thu Dec 10, 2009 8:13 am

Getting Error While doing Regular Pattern Matching--- Trim

Post by Niroj@Work » Mon Dec 14, 2009 1:41 pm

SRT>Trim
Let>TrimmedStr=Trim_Var_1
//Trimming out spaces at beg and end
RegEx>^\s+,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr
RegEx>\s+$,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr

//Trimming out any invisible chracters
RegEx>^[^\d\w\~`!@#$%^&*()_\-+={}|\\\]\["':;?/.>,[^\d\w\~`!@#$%^&*()_\-+={}|\\\]\["':;?/.>,Trim
//-------------------------------------------------------------
Let>TrimmedStr=fxafxggf...invisible chars
GoSub>Trim,%TrimmedStr%
Let>TrimmedStr=,%TrimmedStr%

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

Above I have written the above subroutine to trim all the invisible/spaces at both ends of a string. But while exceution the script showing error prompt that "Regular Pattern didn't Compile"

Why is it happening? I checked in Expresso it is giving me proper result..
Last edited by Niroj@Work on Mon Dec 14, 2009 1:58 pm, edited 1 time in total.

Niroj@Work
Pro Scripter
Posts: 63
Joined: Thu Dec 10, 2009 8:13 am

Re: Getting Error While doing Regular Pattern Matching(Trim)

Post by Niroj@Work » Mon Dec 14, 2009 1:57 pm

Niroj@Work wrote:SRT>Trim
Let>TrimmedStr=Trim_Var_1
//Trimming out spaces at beg and end
RegEx>^\s+,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr
RegEx>\s+$,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr

//Trimming out any invisible chracters
RegEx>^[^\d\w\~`!@#$%^&*()_\-+={}|\\\]\["':;?/.>,[^\d\w\~`!@#$%^&*()_\-+={}|\\\]\["':;?/.>,Trim
//-------------------------------------------------------------
Let>TrimmedStr=fxafxggf...invisible chars
GoSub>Trim,%TrimmedStr%
Let>TrimmedStr=,%TrimmedStr%

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

Above I have written the above subroutine to trim all the invisible/spaces at both ends of a string. But while exceution the script showing error prompt that "Regular Pattern didn't Compile"

Why is it happening? I checked in Expresso it is giving me proper result..

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 14, 2009 5:13 pm

You have commas in your pattern. Do this:

Code: Select all

SRT>Trim
  Let>TrimmedStr=Trim_Var_1
  //Trimming out spaces at beg and end
  RegEx>^\s+,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr
  RegEx>\s+$,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr

  //Trimming out any invisible chracters
  Let>pattern=^[^\d\w\~`!@#$%^&*()_\-+={}|\\\]\["':;?/.>,<]+
  RegEx>pattern,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr

  Let>pattern=[^\d\w\~`!@#$%^&*()_\-+={}|\\\]\["':;?/.>,<]+$
  RegEx>pattern,%TrimmedStr%,0,matchArr,TotMatches,1,,TrimmedStr
END>Trim
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts