pigmentarts
asked on
Regex statment please!
i am not the best at this regex stuff, so anyone help would be much welcome, i have the statment below, it removes all the whitespace, but its works too well ie it buts all the outputted code one to one line. it does work well but i still want to retain and nice html look not unreadable code
does anyone know regex to edit below to do this?
(Content,"[[:space:]]{2,}" ,"","ALL") #
does anyone know regex to edit below to do this?
(Content,"[[:space:]]{2,}"
ASKER
ok i will have a go now
ASKER
strange the above did not seem to do anything at all, maybe i am using it wrong, below is the one that works (too well)
<cfhttp method="get" url="#productPageTemplate# ?prodId=#F ORM.prodId #" />
<cfset productPageContent.sHTTPDa ta = CFHTTP.FileContent>
<cfset productPageContent.sDataCl ean = reReplace(productPageConte nt.sHTTPDa ta,"[[:spa ce:]]{2,}" ,"","ALL") >
<cffile action="write" output="#productPageConten t.sDataCle an#" file="#productPageLocation #/#product PageName#. html" nameconflict="overwrite">
<cfhttp method="get" url="#productPageTemplate#
<cfset productPageContent.sHTTPDa
<cfset productPageContent.sDataCl
<cffile action="write" output="#productPageConten
ASKER
i replaced this "[[:space:]]{2,}","","ALL" with this "[ ]+", " ", "ALL" etc from the above but did nothing.
Just for laughs, try changing (Content,"[[:space:]]{2,}" ,"","ALL") # to (Content,"[[:space:]]{2,-} ","","ALL" )#
Also, would it be possible for you to post or host the output that contains the whitespace, so that we can see the format that needs to be cleaned up?
Also, would it be possible for you to post or host the output that contains the whitespace, so that we can see the format that needs to be cleaned up?
ASKER
ok hang on lets see,
ASKER
nothing happened, it only works with "[[:space:]]{2,}","","ALL" ?
here is a link to the page using this "[[:space:]]{2,}","","ALL" look at the source it works but buts all on one line. if i did not use it they page has loads of whitespace (by the way its not a .html page its a cfm thats just my little trick it is coldfusion)
http://www.puffincraft.co.uk.mytempdomain.com/products/test-product.html
here is a link to the page using this "[[:space:]]{2,}","","ALL"
http://www.puffincraft.co.uk.mytempdomain.com/products/test-product.html
I see whats goin on with the output page using the above code, basically removing ALL spaces, if you could be so kind as to let it generate the output WITH the whitespace so that we can experiment.
ASKER
sorry about that just nipped out, anyway, i have taken out the replace so its back to normal: http://www.puffincraft.co.uk.mytempdomain.com/products/test-product.html take a look.
Ahh very cool, now we can see what you mean by whitespace. And yep, thats a LOT of whitespace. Lemme experiment and I'll post again in a bit.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok lets see now
ASKER
o man how can it be that easy lol, you are a star, take a look, works i think, dont spot anything wrong!
(doing a little dance inside)
(doing a little dance inside)
Sure is pretty :) I will go update your other ticket with the solution as well, just in case someone else stubles across that thread instead of this one.
ASKER
no problem, you hav ebeen a big help.
<!--- Replace multiple spaces with a single space --->
<cfset page_text = REReplace(page_text, "[ ]+", " ", "ALL")>
<!--- Replace CRLF followed by multiple spaces with a single space CRLF --->
<cfset page_text = REReplace(page_text, "#Chr(13)##Chr(10)#[ ]*", Chr(13) &
Chr(10), "ALL")>
taken from http://lists.evolt.org/archive/Week-of-Mon-20030224/135598.html