Extract string from a string 
Author Message
 Extract string from a string

Hi,
   How can i extract the string ' http://www.*-*-*.com/ ' from string

Cheers,
Aldoliu Chan
==========================================================================





Sun, 12 Dec 1999 03:00:00 GMT  
 Extract string from a string

Quote:

> Hi,
>    How can i extract the string 'http://www.intel.com/' from string

> Cheers,
> Aldoliu Chan
> ==========================================================================




Look into regexps there is more than enough info on this in the FAQ and
some regexp specific documentation at http://www.perl.com. Have a play
and if you are still stuck come back with a snippet of your efforts.

simple(ish) example:

perl -e '"http://www.perl.com/" =~ /http:\/\/([^\/]*)/; print "\n$1\n"'



Sun, 12 Dec 1999 03:00:00 GMT  
 Extract string from a string

Quote:
> Hi,
>    How can i extract the string 'http://www.intel.com/' from string


  Parsing href's can be a difficult task (in this case I would recommend the
HTML::Parser module). If you always believe your string will be like this, then
you can do:

$string =~ /HREF="?([^ >"]*)"?/i ;
print "\$match = $1\n" ;

  Here I suppose you do not want the " characters, and I take all characters after the HREF= sentence.
This will be buggy in many case, so please have a look to HTML::Parser.

  Cheers,                           Jean-Damien.

--
       *******************************************************
       *                 Jean-Damien Durand                  *

       *        www   : http://wwwcn1.cern.ch/~ddurand/      *
       *******************************************************
--
       *******************************************************
       *                 Jean-Damien Durand                  *

       *        www   : http://wwwcn1.cern.ch/~ddurand/      *



Sun, 12 Dec 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. extract string from another string

2. regular expression to extract a string between 2 other strings

3. Extracting strings from postscript in a single regexp?

4. Extracting strings with Perl.

5. extracting error strings from C source

6. Extracting Specific Chars from a Whole Large String

7. How to extract the toplevel-domain of a domainame from a string with regexp

8. Extract a substring in middle of a string.

9. How do you extract bits from a string?

10. How can I extract C'string

11. extracting strings from c-source ?

12. : Extracting matches from a string

 

 
Powered by phpBB® Forum Software