Link to home
Start Free TrialLog in
Avatar of pigmentarts
pigmentartsFlag for United Kingdom of Great Britain and Northern Ireland

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")#
Avatar of aseusainc
aseusainc

Try one or both of these:

<!--- 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

Avatar of pigmentarts

ASKER

ok i will have a go now
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=#FORM.prodId#" />
<cfset productPageContent.sHTTPData = CFHTTP.FileContent>
<cfset productPageContent.sDataClean = reReplace(productPageContent.sHTTPData,"[[:space:]]{2,}","","ALL")>    

<cffile action="write" output="#productPageContent.sDataClean#" file="#productPageLocation#/#productPageName#.html" nameconflict="overwrite">
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?
ok hang on lets see,
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
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.
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
Avatar of aseusainc
aseusainc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok lets see now
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)
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.
no problem, you hav ebeen a big help.