Re: Split String

2010-12-06 Thread Azadi Saryev

listrest(listlast(thestring, .), /\) should give you 
'var1/var2/var3/var4'

Azadi

On 06/12/2010 23:06 , Robert Harrison wrote:
 I have a string like this:  
 thislocation/thisdir/thissite/thispage.cfm/var1/var2/var3/var4

 I want to split the string to get just that data that follows .cfm/, which 
 would be var1/var2/var3/var4.

 Tried all the list function I can think of, but that's not the right 
 approach.  How can all get only the data that follows the literal .cfm/?

 Thanks


 Robert B. Harrison
 Director of Interactive Services
 Austin  Williams
 125 Kennedy Drive, Suite 100
 Hauppauge NY 11788
 P : 631.231.6600 Ext. 119
 F : 631.434.7022
 http://www.austin-williams.com

 Great advertising can't be either/or.  It must be.

 Plug in to our blog: AW Unplugged
 http://www.austin-williams.com/unplugged




 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339812
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Split String

2010-12-06 Thread Michael Grant

ListRest(yourList,/)


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339813
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Split String

2010-12-06 Thread Rick Root

How about this...

cfset mylist = reReplace(mylist,.*?\.cfm/,,ONE)

seems to work.


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339814
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Split String

2010-12-06 Thread Greg Morphis

I love that about this list.. you can always learn something new..
I used:
cfset foorl =
thislocation/thisdir/thissite/thispage.cfm/var1/var2/var3/var4

cfset length = len(foorl)+1 /
cfset pos = find(.cfm/, foorl) + len(.cfm/)/


cfset foo = mid(foorl, pos, length) /

cfoutput#foo#/cfoutput



On Mon, Dec 6, 2010 at 9:23 AM, Rick Root rick.r...@gmail.com wrote:


 How about this...

 cfset mylist = reReplace(mylist,.*?\.cfm/,,ONE)

 seems to work.


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339815
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Split String

2010-12-06 Thread Robert Harrison

 listrest(listlast(thestring, .), /\) should give you 'var1/var2/var3/var4'

This seems to be working.  Thanks for the assist. Now I'll share the results. 

What I wanted to do was break any url containing obfuscated vars into into 
elements I could work with for queries, etc. This now seems to be working to do 
just that, regardless of the URL structure.

Now I can use urls like ... http://mypage.cfm/var1/var2/var3 instead of urls 
like http://mypage.cfm?var1=value1var2=value2var3=value3 Much better for SEO.

cfset url_vars=#listrest(listlast(cgi.REQUEST_URI, .), /\)# / !--- 
strips the variables obfuscated as '/' delmited values from the URI string ---
cfset url_var_count=#listlen(url_vars, /)# !--- counts the number of 
variables ---
cfif url_var_count gt 0
cfloop from=1 to=#url_var_count# index=i
cfset url_var#i#=#listGetAt(url_vars, i,  /)# !--- 
extracts variables and assigns each a numbered value 'url_varX'  ---
/cfloop
/cfif

!--- below is only used to see output list of created variables; not really 
needed to use the variables ---
cfif url_var_count gt 0
cfoutput
cfloop from=1 to=#url_var_count# index=i
Variable#i#=#evaluate(url_var#i#)#br /
/cfloop
/cfoutput
cfelse
No / delimited variables found in URL string
/cfif

Robert B. Harrison
Director of Interactive Services
Austin  Williams
125 Kennedy Drive, Suite 100 
Hauppauge NY 11788
P : 631.231.6600 Ext. 119 
F : 631.434.7022
http://www.austin-williams.com 

Great advertising can't be either/or.  It must be .

Plug in to our blog: AW Unplugged
http://www.austin-williams.com/unplugged



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339817
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Split String

2010-12-06 Thread Larry Lyons

I'd use CF's underlying java core in this case, as in:

cfset theList = 
thislocation/thisdir/thissite/thispage.cfm/var1/var2/var3/var4 
cfset theOtherPart = theList.split(.cfm) /
cfset theLastPart = theOtherPart[2] /

cfset request.cfdumpinited = false /
cfdump label=theOtherPart  var=#theOtherPart# expand=true /
cfdump label=theLastPart  var=#theLastPart# expand=false /
cfabort /

hth,
larry

 I have a string like this:  thislocation/thisdir/thissite/thispage.
 cfm/var1/var2/var3/var4
 
 I want to split the string to get just that data that follows .cfm/, 
 which would be var1/var2/var3/var4.
 
 Tried all the list function I can think of, but that's not the right 
 approach.  How can all get only the data that follows the literal .
 cfm/?
 
 Thanks
 
 
 Robert B. Harrison
 Director of Interactive Services
 Austin  Williams
 125 Kennedy Drive, Suite 100 
 Hauppauge NY 11788
 P : 631.231.6600 Ext. 119 
 F : 631.434.7022
 http://www.austin-williams.com 
 
 Great advertising can't be either/or.  It must be .
 
 Plug in to our blog: AW Unplugged
 http://www.austin-williams.com/unplugged
 
 


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339851
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Split String

2010-12-06 Thread Andrew Scott

How is that any different to listGetAt(list, 2, '.cfm/') and its shorter
code.

Regards,
Andrew Scott
http://www.andyscott.id.au/


 -Original Message-
 From: Larry Lyons [mailto:larrycly...@gmail.com]
 Sent: Tuesday, 7 December 2010 9:01 AM
 To: cf-talk
 Subject: Re: Split String
 
 
 I'd use CF's underlying java core in this case, as in:
 
 cfset theList =
 thislocation/thisdir/thissite/thispage.cfm/var1/var2/var3/var4  cfset
 theOtherPart = theList.split(.cfm) / cfset theLastPart =
theOtherPart[2]
 /
 
 cfset request.cfdumpinited = false /
 cfdump label=theOtherPart  var=#theOtherPart# expand=true /
 cfdump label=theLastPart  var=#theLastPart# expand=false /
 cfabort /
 
 hth,
 larry
 
  I have a string like this:  thislocation/thisdir/thissite/thispage.
  cfm/var1/var2/var3/var4
 
  I want to split the string to get just that data that follows .cfm/,
  which would be var1/var2/var3/var4.
 
  Tried all the list function I can think of, but that's not the right
  approach.  How can all get only the data that follows the literal .
  cfm/?
 
  Thanks
 
 
  Robert B. Harrison
  Director of Interactive Services
  Austin  Williams
  125 Kennedy Drive, Suite 100
  Hauppauge NY 11788
  P : 631.231.6600 Ext. 119
  F : 631.434.7022
  http://www.austin-williams.com
 
  Great advertising can't be either/or.  It must be .
 
  Plug in to our blog: AW Unplugged
  http://www.austin-williams.com/unplugged
 
 
 
 
 ~~
 ~~~|
 Order the Adobe Coldfusion Anthology now!
 http://www.amazon.com/Adobe-Coldfusion-
 Anthology/dp/1430272155/?tag=houseoffusion
 Archive: http://www.houseoffusion.com/groups/cf-
 talk/message.cfm/messageid:339851
 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
 Unsubscribe: http://www.houseoffusion.com/groups/cf-
 talk/unsubscribe.cfm


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339857
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Split String

2010-12-06 Thread Michael Grant

First my earlier post completely disregarded the fact that you'd have /
chars BEFORE the .cfm, so sorry about neglecting that tid bit.

Secondly I'd like to recommend not using so many #'s where they aren't
needed. I've worked the code below to illustrate what I mean. Also, to avoid
#'s on the left hand side of assignment as well as reducing the use of
evaluate I'd recommend using either a struct or an array for storing your
url_var vars.

cfset url_vars = listrest(listlast(cgi.REQUEST_URI, .), /\) / !---
strips the variables obfuscated as '/' delmited values from the URI string
---
cfset ary_vars = ListToArray(url_vars,/,true) / !--- Create array of
vars ---

!--- below is only used to see output list of created variables; not really
needed to use the variables ---
cfif ArrayLen(ary_vars)

cfoutput

cfloop from=1 to=#ArrayLen(ary_vars)# index=i

Variable#i# = #ary_vars[i]#br /

/cfloop

/cfoutput

cfelse
   No / delimited variables found in URL string
/cfif


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339864
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm