Jump to content
Sign in to follow this  
Champak

StringRegExpReplace help with html tags

Recommended Posts

Could someone who me how to remove '<' and '>' and everything between them please? Basically replace it with nothing.

Edited by Champak

Share this post


Link to post
Share on other sites

local $s = "Some Stuff <and> Some Other Stuff"

msgbox(0, '' , $s)

$sOut = StringRegExpReplace($s , "<.*>" , "")

msgbox(0, '' , $sOut)


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Might want to watch for nested:

Global $gsString = "i am <something<here><something> else>a string"
ConsoleWrite(StringRegExpReplace($gsString, "<.*[^<]>", "") & @CRLF)
Edited 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.

Share this post


Link to post
Share on other sites

?  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 by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Ah, when it comes to regex I'm constantly afraid I am overlooking something I should have learned a long time ago.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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 by Champak

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...