Champak Posted January 20, 2015 Share Posted January 20, 2015 (edited) Could someone who me how to remove '<' and '>' and everything between them please? Basically replace it with nothing. Edited January 20, 2015 by Champak Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted January 20, 2015 Share Posted January 20, 2015 (edited) What have you tried? Edited January 20, 2015 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
iamtheky Posted January 20, 2015 Share Posted January 20, 2015 local $s = "Some Stuff <and> Some Other Stuff" msgbox(0, '' , $s) $sOut = StringRegExpReplace($s , "<.*>" , "") msgbox(0, '' , $sOut) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 (edited) Might want to watch for nested: Global $gsString = "i am <something<here><something> else>a string" ConsoleWrite(StringRegExpReplace($gsString, "<.*[^<]>", "") & @CRLF) Edited January 20, 2015 by SmOke_N 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...
iamtheky Posted January 20, 2015 Share Posted January 20, 2015 (edited) ? What are you accounting for that I am missing Global $s = "i am <something<here><something> else>a string" $sOut1 = StringRegExpReplace($s , "<.*>" , "") $sOut2 = StringRegExpReplace($s, "<.*[^<]>", "") msgbox(0, '' , $sOut1) msgbox(0, '' , $sOut2) Edited January 20, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 I changed it to that... I had a lazy quantifier in it before and realized it didn't remove the last forward arrow, so I just removed the lazy without checking if it made a diff... 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...
iamtheky Posted January 20, 2015 Share Posted January 20, 2015 Ah, when it comes to regex I'm constantly afraid I am overlooking something I should have learned a long time ago. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Champak Posted January 20, 2015 Author Share Posted January 20, 2015 (edited) Thanks I tried it but it doesn't work for me...most likely because of the nested feature, I don't know. I tried editing it, but cant get the results I want. Here's an example of what I would need to edit. I don't think I'll ever come across a need for nested in this particular need. MsgBox(0,0,StringRegExpReplace("6.~Keep <b>right</b> to continue on <b>white plains blah blah Rd</b><div style='font-size:0.9em'>Destination will be on the right</div>~94((48.8388154, -78.8598753))", "<.*[^<]>", "")) Edited January 20, 2015 by Champak Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 Try this... local $string = "6.~Keep <b>right</b> to continue on <b>white plains blah blah Rd</b><div style='font-size:0.9em'>Destination will be on the right</div>~94((48.8388154, -78.8598753))" MsgBox(0,0,StringRegExpReplace($string,"<.*?[^<]>", " ")) Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Champak Posted January 20, 2015 Author Share Posted January 20, 2015 Thanks, that's perfect. I would never have thought of the question mark. Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 Glad it worked. I just altered the patterns from above from greedy to non-greedy and added a space for readability. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 Um... try running that on my string kylomas, that's the exact expression I had that I changed. 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...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 @SmOken_N - Yes, I alluded to your answer in my response. The OP says that there will be no nested groups... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 (edited) k, well "<.*?>" would work the same then. Edit: This might be better so there aren't leading and trailing spaces even. StringRegExpReplace($sString, "(?s)\h*<.*?>\h*", " ") Edited January 20, 2015 by SmOke_N 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...
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