Elijah has asked for the wisdom of the Perl Monks concerning the following question:
I need a way to return just the matched pattern from the whole matched string. I cannot think of a way to seperate the pattern from it's string.
Here is an example program I have to test against my own site for example.
Any help is appreciated.#!/usr/bin/perl -w use strict; use LWP::Simple; my($target, $response); if (!$ARGV[0]) { print "Enter launch site! (don't forgot to include the \"http://\") +\n"; exit(0); } while (1) { exit(0) if(($target) && ($target eq $target)); $target = $ARGV[0] unless($target); $response = get($target) || die "Cannot get page!\n"; my @results = split(/ /, $response); foreach (@results) { if ($_ =~ m/(http\:\/\/).+/) { print "URL found: ".$_,"\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extract substring from string with no whitespace using regexp?
by mildside (Friar) on Feb 26, 2004 at 03:23 UTC | |
by ysth (Canon) on Feb 26, 2004 at 04:27 UTC | |
|
Re: Extract substring from string with no whitespace using regexp?
by graff (Chancellor) on Feb 26, 2004 at 06:03 UTC | |
|
Re: Extract substring from string with no whitespace using regexp?
by Abigail-II (Bishop) on Feb 26, 2004 at 10:30 UTC | |
|
coding standards
by TomDLux (Vicar) on Feb 26, 2004 at 18:02 UTC |