[Bioperl-l] A perl regex query

Roy Chaudhuri rrc22 at cam.ac.uk
Tue Sep 18 08:03:22 EDT 2007


> 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.
> 

A more general approach that might work is to keep lower case words (I 
don't know if that will be true for all your cases):

$_='Cyclic-2,3-bisphospho-D-glycerate';
print join '', /\b[a-z]+\b/g;

Roy.
--
Dr. Roy Chaudhuri
Department of Veterinary Medicine
University of Cambridge, U.K.


More information about the Bioperl-l mailing list