Jump to content
Sign in to follow this  
michaelslamet

String Manipulation (RegEX ??) question

Recommended Posts

michaelslamet
kylomas

Hi ms, long time no talk...

Try this...

local $str = '[Never delete this]And this [url="http://OnlyDeleteThis.com"]and dont delete this too'
ConsoleWrite(stringregexpreplace($str,'(.*)\[url=.*\](.*)','$1 $2') & @LF)

kylomas

edit: additional info

If the pattern to delete occurs multiple times in the string then try this... 

local $str = '[Never delete this]And this [url="http://OnlyDeleteThis.com"]and dont delete this too'
 $str &= '[some more text to not delete]And this [url="http://2ND one to delete.com"]keep the end also'
ConsoleWrite(stringregexpreplace($str,'\[url=[^\]]+\]',' ') & @LF)
Edited by kylomas
  • Like 1

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
michaelslamet

Hi Kylomas,

Yes, quite a long time :)

Yes, the pattern is repeated and the second code works great.

I spend some times trying to figure out how to make the first code working on repeated pattern,

but seems I need to improve my skill :( and bump, like you can read my mind, you post the second code o:)

Thanks a lot, Kylomas :)

Share this post


Link to post
Share on other sites
kylomas

Great, I'm glad it worked.

Enjoy your beautiful island...

kylomas

edit: spelling

Edited by kylomas

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.