extract text from a string

Roberto Bonvallet Roberto.Bonvallet at cern.ch
Thu Nov 9 16:55:57 CET 2006


Jon Clements wrote:
>> I have a string containing: "+abc_cde.fgh_jkl\n" and what I need to
>> become is "abc_cde.fgh_jkl".  Could anybody be so kind and write me a
>> code of how to extract this text from that string?
> 
> [...] Going by your example, it's tempting to suggest the best method
> would be string_name[1:-1] and that you don't need a regex.

...or string_name.lstrip('+').rstrip('\n')

I bet he doesn't need a regexp!
Cheers,
-- 
Roberto Bonvallet



More information about the Python-list mailing list