ColdFusion trim()
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
ColdFusion trim()
I have a string in coldfusion that has several lines. some of the lines are only tabs or blank spaces. I want to remove any line that does not have some text in it. Anybody know how to go about doing this?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
From quick searching it appears there is a Trim() method.
http://livedocs.adobe.com/coldfusion/6/ ... pt2109.htm
http://livedocs.adobe.com/coldfusion/6/ ... pt2109.htm
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
aye yes but my problem is removing the blank lines, maybe my topic title was a little misleading. like in php i would do this:
How would I do this in coldfusion?
Code: Select all
$Arr = explode("\n", $Text);
$Clean = array();
foreach ($Arr as $val)
{
$val = trim($val);
if ('' != $val)
{
$Clean[] = $val;
}
}
$Text = implode("\n", $Clean);- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Sounds like the best idea. Here is what I tried to no avail:
i dont believe this warrants a new thread in the Regex forum but if it does lemme know.
Code: Select all
<cfset works = REReplace(#works#, "^[a-z0-9A-Z]", "", "ALL")>- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
I dont follow you but I believe if I showed you an example of the text im dealing with we might be able to figure this out.feyd wrote:Is ^,$ line anchors or the entire string's anchors?
Code: Select all
!TRNS TRNSID TRNSTYPE DATE ACCNT NAME AMOUNT DOCNUM TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 SADDR1 SADDR2 SADDR3 SADDR4 SADDR5
!SPL SPLID TRNSTYPE ACCNT AMOUNT DOCNUM MEMO PRICE QNTY INVITEM
!ENDTRNS
TRNS ? INVOICE ? Accounts Receivable Woodward Pharmacy 549.60 ? Y Gathagan Investment Co David Deininger 29 South Second Street Clearfield, PA 16830 ? Woodward Pharmacy 565 Springstreet Houtzdale, PA 16651 ? ?
SPL 1 INVOICE ? -549.60 ? Week of 01/21/2007 - 01/27/2007 68.70 8 Staffing Hours- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Then I'll have to assume that the anchors are string end markers.
How about...or something similar?
How about...
Code: Select all
\n(?:[[:space:]]*\n)+