gcue Posted March 21, 2011 Posted March 21, 2011 hello. i am trying to do this using stringregexp but don't understand why only 1 character returns in the array #include <array.au3> $string = "AbC12D22" $string = StringUpper($string) $new = StringRegExp($string, "[A-Z]", 1) _ArrayDisplay($new)
UEZ Posted March 21, 2011 Posted March 21, 2011 Because you set the flag to 1 - use 3 but also change search pattern to "(?i)[a-z]".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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
gcue Posted March 21, 2011 Author Posted March 21, 2011 ahhh.. nice! which there was an option to return a string instead of an array.. hassle to go through that array to string conversion
UEZ Posted March 21, 2011 Posted March 21, 2011 You have to invers the search pattern: #include <array.au3> $string = "AbC12D22" $string = StringUpper($string) $new = StringRegExp($string, "(?i)[a-z]", 3) _ArrayDisplay($new) $snew = StringRegExpReplace($string, "(?i)[\d]", "$1") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $snew = ' & $snew & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Bowmore Posted March 21, 2011 Posted March 21, 2011 Strip letters or numbers from string? $string = "AbC12D22" $new = StringRegExpReplace($string, "[0-9]", "") ; Reslts in $new = "AbCD" MsgBox(0,"Result",$New) ; $new = StringRegExpReplace($string, "[^0-9]", "") ; Reslts in $new = "1222" MsgBox(0,"Result",$New) ; "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
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