--- In [email protected], "jbkilian" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> I want to replace a text string placed within squared bracket with an
> empty string. For example:
> 
> sString="Hello [World]"
> 
> should get to 
> 
> sStringAfterReplace="Hello "
> 
> I tried this using the regex-plugin. But I failed with escaping the
> square bracket. What I did (I concentrate on the square bracket
escaping):
> 
> returnCode=regex.replaceg(sString,"\[","",output)
> 
> The return code was 8 which indicates a wrong pattern ("\[").
> 
> Any idea how to escape the square brackets correctly?
> 
> How can I solve my original problem: replace the substring within the
> square brackets with an empty string (including replacing the square
> brackets) ? In Perl the correct pattern is "\[.*\]" - but this fails
> with the regex-dll, cause of problems escaping square brackets ...

Try putting a "?" in front of your strings.  Most likely, the "\" is
the escape character on your setup (this is the default), so PowerPro
is escaping your bracket before passing it to the regex plugin. 
Putting the question mark in front of the string will stop that from
occuring.

Here is a working script that I believe does what you want.
   local sString, output
   sString="Hello [World]"
   win.debug(regex.replaceg(sString,?"\[.*\]","","output"))
   win.debug(output)

This produces an assignment to "Hello" to the output variable

Paul






------------------------ Yahoo! Groups Sponsor --------------------~--> 
You can search right from your browser? It's easy and it's free.  See how.
http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/JV_rlB/TM
--------------------------------------------------------------------~-> 

Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to