Help with regex match and replace

Discussion in 'Questions (Windows Mobile)' started by tsteward, Sep 2, 2008.

  1. tsteward

    tsteward Active Member Licensed User

    Would anyone be able to knock up a quick routine so I can learn how to implement Regex controls.

    I wish to search a string to find all occurrences of "*" some text and "*"
    Then replace it with "<b>" the text "</b>"

    Playing around with a regex builder I have come up with this code to find the matches:
    \*([^\*]+)\*

    And this regex to replace the text:
    <b>$1<\\b>

    So my question is how do I implement this into basic 4 ppc.

    Thank you
    Tony
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Something like:
    Code:
    Sub App_Start
        str = 
    "This is a string: * lskjefklew f* wef wl;efkl;wef * fwel;fkw;lkgweg wegwegweg* WEG* wegjlweg=-3t94=-9t*"
        
    regex.New1("\*([^\*]+)\*")
        newStr = 
    regex.Replace(str,"<b>$1<\b>")
        
    Msgbox(newStr)
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice