Re: [MacPerl-AnyPerl] Word filter

[email protected] (Thomas Wegner) Wed, 29 Jan 2003 18:21:43 +0100
Newsgroups perl.macperl.anyperl
Message-ID <p04320400ba5dbc8181c0@[149.225.14.175]>
At 14:49 Uhr +0100 29.01.2003, Eelco Alosery wrote:
>From a string I want to filter out what is between [ and ]
>$word must now contain what stands there.
>Bur there is no telling where the [ and the ] stands so it must 
>delete al what is in front of [ and what is after ]

Try something like this:

#!perl -w

$string = 'This is [a test] string';

$string =~ m/.*\[(.*)\].*/;

$word = $1;

print "word= -$word- \n";

__END__


Also see the m/PATTERN/cgimosx matching operator in perlop.pod and 
read the Perl regular expression manpage perlre.pod.


HTH,
Thomas