[Bioperl-l] A perl regex query
spiros at lokku.com
Tue Sep 18 08:23:49 EDT 2007
Its not impossibe, you just have to use \b to denote the word boundaries :)
echo 'this-is-a_test-D-string-D' | perl -ne ' s/\b\-D\-\b//g ; print ;'
It only gets rid of -D- , all other occurrences of D and - remain intact.
On 9/18/07, neeti somaiya <neetisomaiya at gmail.com> wrote:
> It might work, but not always, because the string could be somthing like
> Here I will first convert the full thing to a lower case and would then try
> to get what I want.
> Nothing seems to work, when I try to substitute -D- with nothing, "D" and
> "-" when occuring separately also get substituted with nothing.
> On 9/18/07, Roy Chaudhuri <rrc22 at cam.ac.uk> wrote:
> > > 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.
> Even my blood says, B positive
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
More information about the Bioperl-l