Solved

How can I remove a list of items after found item?

Posted on 2014-12-29
2
79 Views
Last Modified: 2014-12-30
Hello,

I would like to be able to remove a list of items after another found list item.

A example list item could be : "3000-SE-Pine-St-Seattle-WA-99200"

I wanted to be able to capture everything before "Seattle" but I was thinking a second list could be used to delete everything after any matched 2nd list items.

<cfset streetTypeSuffix = "dr,st,lk,rd,ave,ln,way,ct,loop,blvd,hwy,cir">

So expected results would be... "3000-SE-Pine-St"

Problem is if Seattle is a two word city so I can't always just use "listDeleteAt" @ positions 1,2 & 3 but I do know the values in "streetTypeSuffix" list.
0
Comment
Question by:brihol44
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
Unfortunately, CF doesn't have much in the way of "sub list" functions. So you have to loop in order to reconstruct the list. Another option is to try a regex like:

<cfset text = "3000-SE-Pine-Blah-Seattle-WA-99200">
<cfset newText = reReplaceNoCase(text, "\-(dr|st|lk|rd|ave|ln|way|ct|loop|blvd|hwy|cir)\-.+$", "-\1")>
<cfdump var="#newText#">

Open in new window

0
 

Author Closing Comment

by:brihol44
Comment Utility
Nice AGX! Thx, works.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now