Copy link to clipboard
Copied
I'm looking to loop through a url string to grab parse out http://, www.twitter.com, and twitter.com.
I thought of first using this:
<cfset form.mystring = REPLACENOCASE(form.mystring, "http://", "", "One")
AND REPLACENOCASE(form.mystring, "www.twitter.com", "", "One")>.
I realized that this won't work of course.
Additionally, using a cfif-cfelseif in this case will remove an one condtion, but not multiple condition.
Need to use a cfloop I think. Any suggestions on syntax. Thanks
Can't you do:
replacelist(lcase(form.mystring),"http://,www.twitter.com,twitter.com",",,,")
?
Copy link to clipboard
Copied
Can't you do:
replacelist(lcase(form.mystring),"http://,www.twitter.com,twitter.com",",,,")
?
Copy link to clipboard
Copied
An alternative would be to use a regex (which seems - to me - to be a more natural solution here):
reReplaceNoCase(form.myString, "^http://(?:www\.)?twitter\.com", "", "ONE")
--
Adam
Copy link to clipboard
Copied
Have you checked to see what is available on CFLIB.ORG? I'm pretty sure that there are a number of functions there for disecting URL strings.
-reed