Like this... -- code --
my $text = "Hello 1234, come in"; $text =~ /(\d{4,4})/; $match = $1 if $1; print $match; -- end code -- By putting brackets round the section of the regex you want, perl will store that data in the special $1 variable (it's read only so assign to another var if you want to make changes. Also the next time you match $1 is overwritten). You can pull multiple values out of the same regex by putting multiple () round different sections. The results are stored in $1, $2, $3 etc in the order of the match. HTH John -----Original Message----- From: WaspCatcher [mailto:[EMAIL PROTECTED]] Sent: 21 November 2001 09:49 To: [EMAIL PROTECTED] Subject: extracting *just* matched text hi, how does one extract *just* the matched text in a regular expression, e.g. my $text = "Hello 1234, come in"; if ($text =~ /\d{4,4}/) { #grab just the 4 digit number } thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]