Home > Community > Forums > Custom IC SKILL > search & replace in a sting

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 search & replace in a sting 

Last post Mon, Feb 8 2010 4:26 PM by The Consultant. 2 replies.
Started by The Consultant 08 Feb 2010 03:11 PM. Topic has 2 replies and 2175 views
Page 1 of 1 (3 items)
Sort Posts:
  • Mon, Feb 8 2010 3:11 PM

    search & replace in a sting Reply

    string="1!2! 3 4"

    should become

    string="1234"

     so remove all " " and "!"

     

    how can i do this

     

    regex ?

     

     

     

     

    • Post Points: 20
  • Mon, Feb 8 2010 3:28 PM

    Re: search & replace in a sting Reply

    Since you're using IC613 (from your previous post), you could use the newer "pcre" (Perl Compatible Regular Expression) functions which are more powerful than the older "rex" functions. For example:

    pat=pcreCompile("[!\\s]")
    string=pcreReplace(pat string "" 0)

    The \\s (extra escape needed because the pattern really needs a backslash, but backslash is used in SKILL, so needs to be escaped) means whitespace. So it will match space, tab, etc.

    You could also use the older functions:

    rexCompile("[! ]")
    string=rexReplace(string "" 0)

    The PCRE-based functions are really powerful, and so I'd recommend those in general if you don't need to make code also work in IC5141 (which only had the older rex functions)

    Regards,

    Andrew.

     

    • Post Points: 20
  • Mon, Feb 8 2010 4:26 PM

    Re: search & replace in a sting Reply

     that works fine.

     

    thx. Andrew

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by The Consultant at 08 Feb 2010 03:11 PM. Topic has 2 replies.