tsteward Well-Known Member Licensed User Longtime User Sep 2, 2008 #1 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
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
Erel B4X founder Staff member Licensed User Longtime User Sep 2, 2008 #2 Something like: B4X: 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
Something like: B4X: 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