View Single Post
  #36  
Old 01-25-2008, 04:05 PM
Jimbo's Avatar
Jimbo Jimbo is offline
Senior Member
 
Join Date: Nov 2004
Posts: 961
Default

Now I feel bad I opened that "can of worms"...

//
// Ignore These - So you don't need to process any of these in any way. Just leave them as is.
//
// Yes - Ignoring these embedded URL might not be so simple...

< img src="http://photo_link" height=xxx width=xxx border=2 >

< a href="http://photo_link" target="_blank">Photo Title or Name< /a >

< a href="_link_" target="_blank">_link_< /a >

< object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/__video__code"></param><param name="wmode" value="transparent"></param>< embed > < /embed ></object>

< embed> ___whatever__ </embed>

[ url ]__Link__[ /url ]

[ img ]__Link__[ /img ]

... etc., etc.,...

//
// Only Process These (Independent String Tokens) - & Ignore Everything Else
//

"http://__any__length__string__token___" ==> [ url ]http://__any__length__string__token___[ /url ]

"https://__any__length__string__token___" ==> [ url ]http://__any__length__string__token___[ /url ]

"www.__any__length__string__token___" ==> [ url ]www.__any__length__string__token___[ /url ]

//
// Summary - Simplified "C" Code Algorithm (Other Details & Complexities Omitted)
//
// NOTEs:
// 1) Tokens here are delimited by "white blank spaces" (space, newline, tabs, etc.)
// \n - newline
// \t - horizontal tab
// \v - vertical tab
// \b - backspace
// \r - carriage return
// \f - formfeed
//
// 2) URLs will become a string token as delimited by "white blank spaces".
//
// The entire single entity "token" will be the URL.
//
// This assumes that a URL will start w/ either ( http://, https://, www., or other known header), &
// it will end w/ a "white blank space".

Code:
   char string_token[1025], p[2025];
   string_token[0] =  '\0';
   p[0] =  '\0';

   while(get_next_string_token(string_token)) {            // get next token - pseudo code
      strncpy(p,string_token,1024);                        // make a copy

      if(strncmp(string_token,"http://",7) == 0) {         // if "http" URL
          tag_untagged_URL(p);                             // tag that animal
          output(p);                                       // output fixed URL
      } else if(strncmp(string_token,"https://",8) == 0) { // else if "https" URL
          tag_untagged_URL(p);                             // tag that animal
          output(p);                                       // output fixed URL
      } else if(strncmp(string_token,"www.",4) == 0) {     // else if "www." URL 
          tag_untagged_URL(p);                             // tag that animal
          output(p);                                       // output fixed URL
      } else {
         output(string_token);                             // output unprocessed string token - pseudo code
      }
   }
Reference: strncmp
http://www.cplusplus.com/reference/c...g/strncmp.html

Reference: strtok
http://www.cplusplus.com/reference/c...ng/strtok.html
__________________
Freedom is to understand, & to be unbounded by that Freedom -
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.

Last edited by Jimbo : 01-25-2008 at 04:35 PM.