wahoyaho Posted November 25, 2007 Share Posted November 25, 2007 (edited) How can I make it check that there's only 1 of a certain character and removes all the rest? So for example if only one character "a" is allowed a string of test1atest2atest3 would become test1atest2test3 Edited November 27, 2007 by wahoyaho Link to comment Share on other sites More sharing options...
wahoyaho Posted November 27, 2007 Author Share Posted November 27, 2007 Anyone know? Link to comment Share on other sites More sharing options...
picaxe Posted November 27, 2007 Share Posted November 27, 2007 Not using regexp, but this will do it $string = "test1atest2atest3" $find = "a" $first = StringInStr($string, $find) If $first > 0 Then $result = StringReplace($string, $find, "") $result = StringLeft($result, $first - 1) & $find & StringRight($result, StringLen($result) - $first + 1) MsgBox(0, "", $result) EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now