Hi there.
I'm trying to write a bit of regex which would go through some text, written by our Editors, and apply an <acronym>
tag to the first instance it finds of an abbreviation set we hold in our "Glossary of Terms".
So for this example I've used the abbreviation ITS
.
1st thing I thought I'd do is setup an example with a mix of scenerios I could test against, i.e. ITS
sitting with punctuation, in HTML tags & ones that we've applied this to already (in other words the script has run through this before, so no need to do again).
I'm almost there but just got stuck at the last point :-(.
Here's the regex I've got so far - <[^<|]+?>?>ITS<[^<]+?>|ITS
The Example - FROM ( EVERY ITS IN BOLD TO BE WRAPPED WITH ACRONYM ):
I want you to tag this
ITS, but not this wrapped one - <acronym title="ITS" id="thisIsATest">ITS</acronym>
This is another test as I still want to update
<p>
ITS</p>
that have other HTML tags wrapped around them.`ITS want ones that start sentences and ones that finish ITS. ITS, and ones which are wrapped in punctuation.`
Test link:
<a href="index.cfm>ITS</a>
AND I WANT THIS CHANGE TO :
I want you to tag this <acronym title="ITS">ITS</acronym>
, but not this wrapped one -<acronym title="ITS">ITS</acronym>
This is another test as I still want to update <acronym title="ITS">ITS</acronym>
that have other HTML tags wrapped around them.`
<acronym title="ITS">ITS</acronym> want ones that start sentences and ones that finish <acronym title="ITS">ITS</acronym>. <acronym title="ITS">ITS</acronym>, and ones which are wrapped in punctuation.
Test link:
<acronym title="ITS"><a href="index.cfm>ITS</a></acronym>
Are there any Reg Ex experts out there that could help me finish this off? Any other hints tips would also be appreciated.
** UPDATE ** Don't know if this helps but this would find the only in that paragraph :
<acronym[^<]*ITS</acronym>
and this will find all the ITS :
<[^<]*>ITS<[^<]*>|ITS
What I really need is a way of combining these to say find all the ITSs but exclude those in tags.
Thanks a lot, James
P.S. This is going to be placed in a ColdFusion application if that helps anyone in specific syntax.