jWalker Posted October 7, 2011 Share Posted October 7, 2011 Hey guys. i need a quick help in the Function StringReplace.. I have a String that contains several substrings. every substring contains a number, which are the first 3 letters of the substring. Then there are some more letters... and finally a " | " I want to Replace the number until the " | " So this: "323)(XXXXXXXXXXXXXXXXX|" becomes This: "" Could anyone help? Link to comment Share on other sites More sharing options...
hannes08 Posted October 7, 2011 Share Posted October 7, 2011 Take a look at StringRegExpReplace, but I'm not into regular expressions, so sorry I can't give you an example. I'm sure you can find a lot of regex ressources on the forum or the web. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 7, 2011 Share Posted October 7, 2011 $checkks = 'test\test?test*323)(XXXXXXXXXXXXXXXXX|"test&test|test/' $REPL = StringRegExpReplace($checkks, '\d{3}.*?\|', '') MsgBox(0, '', $REPL) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jWalker Posted October 7, 2011 Author Share Posted October 7, 2011 (edited) Code-Mega, I dont get the "test"s and "?"s in your code... And the real strings arent "XXXXXXXXXXXX" it could be everything.. Replacing a known string is not what i asked Or i just don't get what you want to tell me #EDIT Ah sorry, youre right!!! Thank you! Edited October 7, 2011 by jWalker Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 7, 2011 Share Posted October 7, 2011 Just try it out. It is variable. Change the XXXX with something eles. The command looks into the given string for 3 numbers then after that all until a | appears and then replaces it with nothing. If that is not what you wanted, then show me some examples of before and after and then I can create the correct pattern for that. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jWalker Posted October 7, 2011 Author Share Posted October 7, 2011 So: "\d{3}" = 3 Numbers... ".*?\" = Until "|" this comes Link to comment Share on other sites More sharing options...
jWalker Posted October 7, 2011 Author Share Posted October 7, 2011 I got sth like this $List = StringReplace( $List, "\"&$hSocket&".*?\|", "|" ) I have a variable... I need to cut the string from the var - until it reaches the | So could you give me the explicit code please? Link to comment Share on other sites More sharing options...
UEZ Posted October 7, 2011 Share Posted October 7, 2011 The best is you post a real example of your text! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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