anixon Posted February 7, 2009 Author Share Posted February 7, 2009 Hmm... Local $a_phone = StringRegExp($s_string, "\d+", 1) If Not @error Then MsgBox(64, "Number", $a_phone[0]) So much to learn so little time the power off the '+' Ant.. Link to comment Share on other sites More sharing options...
anixon Posted February 7, 2009 Author Share Posted February 7, 2009 Given the power of the '+' in this code how would you delete a tab CRLF Whitespace etc should it be present at the beginning of the text $text = " This is an example of" $sMessage = StringRegExpReplace($text, "\s+", " ") Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 7, 2009 Moderators Share Posted February 7, 2009 Given the power of the '+' in this code how would you delete a tab CRLF Whitespace etc should it be present at the beginning of the text $text = " This is an example of" $sMessage = StringRegExpReplace($text, "\s+", " ")StringRegExpReplace($s_string, "(?s)^(\s+)(.*?\z)", "\2") Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
anixon Posted February 7, 2009 Author Share Posted February 7, 2009 StringRegExpReplace($s_string, "(?s)^(\s+)(.*?\z)", "\2") Sorry that does not quite work as it leaves in a carriage return Ant.. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 8, 2009 Moderators Share Posted February 8, 2009 Sorry that does not quite work as it leaves in a carriage return Ant..The carriage return is at the beginning? If you're trying to get rid of all carriage returns, this will do it: StringRegExpReplace($s_string, "[\r\n]+", "") Or StringStripCR() Or StringReplace($s_string, @CR, ""), StringReplace($s_string, @LF, "") My code I posted would remove any space that started at the beginning of the string? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
anixon Posted February 8, 2009 Author Share Posted February 8, 2009 (edited) The carriage return is at the beginning? If you're trying to get rid of all carriage returns, this will do it: StringRegExpReplace($s_string, "[\r\n]+", "") Or StringStripCR() Or StringReplace($s_string, @CR, ""), StringReplace($s_string, @LF, "") My code I posted does remove any space that started at the beginning of the string? Thanks for the reply the code I posted replaces everything that is applicable to to the \s+ flag with a " " space' with the exception that where the first character in the string is a space 'Whitespace?' it is not removed $text = "This is an example of A" $text = " This is an example of B" $sMessage = StringRegExpReplace($text, "\s+", " ") The result would be as follows: 'This is an example A ' This is an example B 'This is an example A ' This is an example B The use of the ' is so as to demonstrate that the text is not left justified because of the space The desired result would all text left justified with single spaces between text and no carage returns as follows: This is an example A This is an example B This is an example A This is an example B Ant.. Edited February 8, 2009 by anixon Link to comment Share on other sites More sharing options...
anixon Posted February 10, 2009 Author Share Posted February 10, 2009 Problem resolved with this code CODE $Text = " This is a copy of text with leading whitespaces and @CRLF" $Txt = StringStripWS(StringRegExpReplace($text, "\s+", " "), 1) Result: This is a copy of text with leading whitespaces and @CRLF" Thanks to those who contributed to this thread... Ant.. 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