gcue Posted March 25, 2015 Share Posted March 25, 2015 hello world.. i am trying to remove the leading spaces for every line in an edit control... i was going to cycle through each line using _GuilCtrlEdit_GetLine and remove the spaces using stringstripws but i think this can probably done faster using stringregexp i found this.. '?do=embed' frameborder='0' data-embedContent>>but it doesnt seem to work when i replace the - with a $ its probably because the $ isnt being read as a literal character so i tried using chr(36) - still didnt work. any ideas? thanks in advance Link to comment Share on other sites More sharing options...
gcue Posted March 25, 2015 Author Share Posted March 25, 2015 (edited) here's a sample data set. $string = " $4 months" & @crlf $string &= " $until notice is due" & @crlf $string & = " $due date = 4/12/2015 " & @crlf Edited March 25, 2015 by gcue Link to comment Share on other sites More sharing options...
jdelaney Posted March 25, 2015 Share Posted March 25, 2015 (edited) $string = " $4 months" & @crlf $string &= " $until notice is due" & @crlf $string &= " $due date = 4/12/2015 " & @crlf ConsoleWrite($string) $string = StringRegExpReplace($string,"(\h+)(.*)","$2") ConsoleWrite($string) Edited March 25, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
iamtheky Posted March 25, 2015 Share Posted March 25, 2015 (edited) $string = " $4 months" & @crlf $string &= " $until notice is due" & @crlf $string &= " $due date = 4/12/2015 " & @crlf $Result = StringRegExpReplace($string, "(?:\n|\A)(\s)*", "") msgbox(0, '' , $string) msgbox(0, '' , $Result) edit: with OPs example rather than link Edited March 25, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
gcue Posted March 25, 2015 Author Share Posted March 25, 2015 jdelaney - worked great!! boththose - i think that strips trailing spaces for each line too thank you very much for your help guys Link to comment Share on other sites More sharing options...
iamtheky Posted March 25, 2015 Share Posted March 25, 2015 (edited) nope: the number, then the expected number of 32s (spaces), followed by a 13 (CR). ** I am however stripping off line feeds.. #include <Array.au3> $string = " 2 " & @crlf $string &= " 3 " & @crlf $string &= " 4 " & @crlf $Result = StringRegExpReplace($string, "(?:\n|\A)(\s)*", "") msgbox(0, '' , $string) msgbox(0, '' , $Result) _ArrayDisplay(StringToASCIIArray($result)) StringRegEx route leaving LF: #include <Array.au3> $string = " 2 " & @crlf $string &= " 3 " & @crlf $string &= " 4 " & @crlf $aResult = StringRegExp($string, "(\H.*\s\n)" , 3) _ArrayDisplay(StringToASCIIArray(_ArrayToString($aResult , ""))) Edited March 25, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
jguinch Posted March 25, 2015 Share Posted March 25, 2015 (edited) $string = " $4 months" & @crlf $string &= " $until notice is due" & @crlf $string &= " $due date = 4/12/2015 " & @crlf ConsoleWrite($string) $string = StringRegExpReplace($string,"(?m)^\h+|\h+$", "") ConsoleWrite($string) Edited March 25, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF 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