Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cf extract substring after url

Participant ,
Jul 26, 2011 Jul 26, 2011

While loopong through query results I am trying to extract the page name from a url.

From this sample url -------  http://www.cnn.com/sports.cfm

I want to extract the name sports.cfm  only

or

From this sample url -------  http://www.msnbc.com/shows.asp

I want to extract the name shows.asp  only

688
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 26, 2011 Jul 26, 2011

I'll give you a clue - think of the string as a list, separated by forward slashes

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 26, 2011 Jul 26, 2011
LATEST

Have you checked CFLIB.ORG?  I think there are number of variations on a function that parses out the parts of a URL.  Also, along Owain's comment, is what I usually do:  Use a CF list function with a delimiter of ? to get the "left" part of a URL, then whack a possible trailing / at the end of what's left, then use a CF list function with a delimiter of / to get the last element of the list.

Many of the CFLIB functions use a regex.  I think that the CFWACK books even use a URL parsing example to show how to use CF regex functions.

-reed

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources