simple regex replacetext question
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 29
- Joined: Mon Apr 09, 2012 8:53 pm
simple regex replacetext question
At least I think it's simple, though I've not figured out the syntax. How should I modify the following so that it works even if the contents of the table tag has a line break and sequence of spaces at the start of the second line? I've tried searching this forum but inevitably find discussions that are more complicated. Regex mostly confounds me, I find myself easily led astray. Thanks in advance!
put replaceText(tVar,"<table.*?>","<table>") into tVar
put replaceText(tVar,"<table.*?>","<table>") into tVar
Re: simple regex replacetext question
While I replace very little text, I think when it comes to replacing html elements, you have to break them up (something to do with Lc parsing html).
For instance, i wrote a little utility to create a blockquote a long time ago. It wouldn't work till I broke the code to create the blockquote itself up -
I also seem to remember this question coming up before a while back. If I come across that thread again, I'll post a link here.
*Edit - it might have been this thread, towards the bottom there are a couple of solutions for html and regex.
For instance, i wrote a little utility to create a blockquote a long time ago. It wouldn't work till I broke the code to create the blockquote itself up -
Code: Select all
put "<blockquote style=" & quote & "background-color: silver;" & quote & ">" & return & "<br>" before field 1
*Edit - it might have been this thread, towards the bottom there are a couple of solutions for html and regex.
Re: simple regex replacetext question
Hi,slindstrom wrote: put replaceText(tVar,"<table.*?>","<table>") into tVar
Please try this one:
Code: Select all
replaceText( tVar,"(?ms)<table[^>]*?>","<table>")
Code: Select all
replaceText( tVar,"(?ms)(?<=<table)[^>]*?(?=>)","")
So take this with a grain of salt, and test it with *your* datas.
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
- VIP Livecode Opensource Backer
- Posts: 29
- Joined: Mon Apr 09, 2012 8:53 pm
Re: simple regex replacetext question
Thanks, Thierry! Both work with my data.
Re: simple regex replacetext question
That's what I'd expect from Thierry, he's the regex hero.
---
Hi Thierry!
Re: simple regex replacetext question
He's the Regex 'ero!
Re: simple regex replacetext question
I'm glad that it works for you.slindstrom wrote: Thanks, Thierry! Both work with my data.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!