in reply to Regular expression question
"I want to extract everything contained within the first pair of parentheses in the given string"
In that case....
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.#!/usr/bin/perl -w use strict; my $string = "Identities = 1529/1540 (99%), Gaps = 2/1540 (0%)"; my ($wanted) = $string =~ m#\((.*?)\)#; print "$wanted\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular expression question
by rangersfan (Novice) on Mar 31, 2006 at 07:40 UTC | |
by gube (Parson) on Mar 31, 2006 at 07:50 UTC | |
by rangersfan (Novice) on Mar 31, 2006 at 07:52 UTC | |
by johngg (Canon) on Mar 31, 2006 at 08:59 UTC |