RE: RegEx to manipulate html tags

2005-04-27 Thread Pascal Peters
REReplace(str, '(img\s[^]*src=)image1\.jpg([^]*)',
\1image2.jpg\2, all)

Pascal

 -Original Message-
 From: Howie Hamlin [mailto:[EMAIL PROTECTED]
 Sent: 27 April 2005 00:52
 To: CF-Talk
 Subject: RegEx to manipulate html tags
 
 Does anyone know of a regex that I can use to replace parameters in
the
 tags of an html page?  For example, I would want to replace the SRC
 parameter of an IMG tag but the SRC parameter is not located in the
same
 postition of the IMG tag each time.  So, as an example:
 
 img src=image1.jpg
 
 img height=100 width=100 src=image1.jpg
 
 should both be converted to:
 
 img src=image2.jpg
 
 img height=100 width=100 src=image2.jpg
 
 If the SRC parameter were always located after the IMG tag start (as
in
 the first example) then I could use a simple findnocase but that's not
the
 case.
 
 Thanks,
 
 --
 Howie Hamlin - inFusion Project Manager
 On-Line Data Solutions, Inc. - www.CoolFusion.com
 inFusion Mail Server (iMS) - The Award-winning, Intelligent Mail
Server
 PrismAV - Virus scanning for ColdFusion and BlueDragon applications
 Find out how iMS Stacks up to the competition:
 http://www.coolfusion.com/imssecomparison.cfm


++
 ++
 iMS-Lite - the completely free mail server solution for applications
and
 application servers
 http://www.coolfusion.com/iMSLite


++
 ++
 
 

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204633
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-27 Thread Claude Schneegans
Hi,

This is an application for CF_REextract; see:
http://www.contentbox.com/claude/customtags/REextract/testREextract.cfm?p=hf

You could easily get all img tags in a recordset, then loop on the 
query and analyse them,
still using CF_REextract.

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204653
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-27 Thread Howie Hamlin
Thanks for all of the replies but what I really need to do is append some text 
in the SRC value.  What I mean is to change this:

img src=image1.jpg

to

img src=/root/images/image1.jpg

I would like to do this for all images in the text and account for both single 
and double quotes.

Thanks,

Howie

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204675
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-27 Thread Claude Schneegans
 what I really need to do is append some text in the SRC value.

Since CF_REextract also returns the exact position and length of every 
string in the text searched,
these strings can easily be changed, replaced or appended.
The trick is to loop backward in the query to make sure the positions of 
all strings are not changed
before.

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204704
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-27 Thread Howie Hamlin
OK, I'll take a look at this.  I read the info on your site and it seems a bit 
daunting to a non-regex person :)

Thanks,

Howie

--- On Wednesday, April 27, 2005 11:18 AM, Claude Schneegans scribed: ---

 what I really need to do is append some text in the SRC value.
 
 Since CF_REextract also returns the exact position and length of every
 string in the text searched,
 these strings can easily be changed, replaced or appended.
 The trick is to loop backward in the query to make sure the positions
 of all strings are not changed
 before.

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204710
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-27 Thread Claude Schneegans
 I read the info on your site and it seems a bit daunting to a 
non-regex person

It may looks so, but on the contrary, it is based on the principle that 
it may sometimes be much easier
to find a string based on context before and after than using only one 
single regex.
Then it actually makes thing easier for a non-regex person.

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204719
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-27 Thread Howie Hamlin
I trust that you're right :)

I just have to roll up my sleeves and knock on wood to ward off the evil regex 
spirits g

Thanks,

Howie

--- On Wednesday, April 27, 2005 11:47 AM, Claude Schneegans scribed: ---

 I read the info on your site and it seems a bit daunting to a
 non-regex person 
 
 It may looks so, but on the contrary, it is based on the principle
 that it may sometimes be much easier
 to find a string based on context before and after than using only one
 single regex.
 Then it actually makes thing easier for a non-regex person.

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204733
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-27 Thread Jochem van Dieten
Howie Hamlin wrote:
 
 img src=image1.jpg
 to
 img src=/root/images/image1.jpg
 I would like to do this for all images in the text and account for both 
 single and double quotes.

Untested:
REReplaceNoCase(theText,(img[^]+src='??)([^']+'??[^]*)),\1/root/images/\2,ALL)

Jochem

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204749
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: RegEx to manipulate html tags

2005-04-26 Thread Ian Skinner
If you use DreamWeaver, recent versions have the ability to find tags with 
attributes and change those attributes.

Check out the Search: option of Specific Tag, I have done exactly what you 
are describing with this capability.

If you use DW.  


--
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA
 
C code. C code run. Run code run. Please!
- Cynthia Dunning

-Original Message-
From: Howie Hamlin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 26, 2005 3:52 PM
To: CF-Talk
Subject: RegEx to manipulate html tags

Does anyone know of a regex that I can use to replace parameters in the
tags of an html page?  For example, I would want to replace the SRC
parameter of an IMG tag but the SRC parameter is not located in the
same postition of the IMG tag each time.  So, as an example:

img src=image1.jpg

img height=100 width=100 src=image1.jpg

should both be converted to:

img src=image2.jpg

img height=100 width=100 src=image2.jpg

If the SRC parameter were always located after the IMG tag start (as in
the first example) then I could use a simple findnocase but that's not
the case.

Thanks,

--
Howie Hamlin - inFusion Project Manager
On-Line Data Solutions, Inc. - www.CoolFusion.com
inFusion Mail Server (iMS) - The Award-winning, Intelligent Mail Server
PrismAV - Virus scanning for ColdFusion and BlueDragon applications
Find out how iMS Stacks up to the competition:
http://www.coolfusion.com/imssecomparison.cfm
+
+++
iMS-Lite - the completely free mail server solution for applications and
application servers
http://www.coolfusion.com/iMSLite
+
+++



~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204594
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RegEx to manipulate html tags

2005-04-26 Thread Howie Hamlin
I need to do this from within a CFML template.

Thanks,

Howie

--- On Tuesday, April 26, 2005 6:57 PM, Ian Skinner scribed: ---

 If you use DreamWeaver, recent versions have the ability to find tags
 with attributes and change those attributes. 
 
 Check out the Search: option of Specific Tag, I have done exactly
 what you are describing with this capability. 
 
 If you use DW.
 
 
 --
 Ian Skinner
 Web Programmer
 BloodSource
 www.BloodSource.org
 Sacramento, CA
 
 C code. C code run. Run code run. Please!
 - Cynthia Dunning
 

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204615
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: RegEx to manipulate html tags

2005-04-26 Thread Jim Davis
 -Original Message-
 From: Howie Hamlin [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 26, 2005 6:52 PM
 To: CF-Talk
 Subject: RegEx to manipulate html tags
 
 Does anyone know of a regex that I can use to replace parameters in the
 tags of an html page?  For example, I would want to replace the SRC
 parameter of an IMG tag but the SRC parameter is not located in the same
 postition of the IMG tag each time.  So, as an example:
 
 img src=image1.jpg
 
 img height=100 width=100 src=image1.jpg
 
 should both be converted to:
 
 img src=image2.jpg
 
 img height=100 width=100 src=image2.jpg
 
 If the SRC parameter were always located after the IMG tag start (as in
 the first example) then I could use a simple findnocase but that's not the
 case.

Do you just want to get the src or are you interested in all the attributes?

If just the source then something like this should do it:

#ReReplaceNoCase(Input, (img.*?src.*?=.*?).*?(.*?),
\1#NewSource#\2)#

You'll have to tweak it.  I'm not even sure it'll run - but I think it will!
The power of positive thinking!

You'll have to make it more complex to also understand things like single
quotes instead of double quotes.

If you want ALL of the attributes then a nice (but, honestly, slow) way to
do it is to find all of the img tags (a regex like img.*? should do
that) rip them out of the source and treat each one like an XML doc (using
XMLParse()).

You can then navigate the tag and its attributes like an XML document.

This will only work on well formed code (so you might have to insert an end
slash if its not there.

Hope this helps,

Jim Davis




~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204626
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54