in reply to Regular expression question

My interpretation of your question:

"I want to extract everything contained within the first pair of parentheses in the given string"

In that case....

#!/usr/bin/perl -w use strict; my $string = "Identities = 1529/1540 (99%), Gaps = 2/1540 (0%)"; my ($wanted) = $string =~ m#\((.*?)\)#; print "$wanted\n";
That outputs 99%, but it may need to be tightened up a bit depending on how accurate my interpretation of your question is, and how much your data varies.

Replies are listed 'Best First'.
Re^2: Regular expression question
by rangersfan (Novice) on Mar 31, 2006 at 07:40 UTC
    what does the m# do? m is for match, but I don't understand what the # does.

      Hi rangersfan,

      (/) This is the usual delimiter for the text part of a regular expression. you can also use (#) as delimiter. By using usual delimiter with regexp i have given the code below you can also refer that for your understand :-p

        learn something new everyday.... thanks!