[Bioperl-l] A perl regex query

Andreas Kahari ak at ebi.ac.uk
Tue Sep 18 08:20:32 EDT 2007


On Tue, Sep 18, 2007 at 04:00:34PM +0530, neeti somaiya wrote:
> Hi,
> 
> This isnt really a bioperl query.
> But does anyone know how I can substitute all special characters (+ some
> other things) in a string with nothing in perl?
> I mean if I have a string like Cyclic-2,3-bisphospho-D-glycerate and I want
> ouput as bisphosphoglycerate. I want to remove -D-, Cyclic-, 2,3- etc.

This is in additions to the suggestions you've already had.

If you always want to concatenate the 3rd and 5th part of the string, as
delimited by dashes, then you could do this:

  my $string = 'Cyclic-2,3-bisphospho-D-glycerate';
  my $newstring = join( '', ( split( /-/, $string ) )[ 2, 4 ] );


Cheers,
Andreas

-- 
Andreas Kähäri :: Ensembl Software Developer
European Bioinformatics Institute (EMBL-EBI)
--------------------------------------------


More information about the Bioperl-l mailing list