extract text from a string

B

boris.smirnov

Hallo all,

I have tried for a couple of hours to solve my problem with re but I
have no success.

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?

thank you very much in advance
regards,
boris
 
J

Jon Clements

Hallo all,

I have tried for a couple of hours to solve my problem with re but I
have no success.

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?

Perhaps if you described what the actual *criteria* is for the
translation; for instance, "I need to keep only letters, numbers and
punctuation characters" etc... 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.

Jon.
 
R

Roberto Bonvallet

Jon said:
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,
 
G

Grant Edwards

Hallo all,

I have tried for a couple of hours to solve my problem with re but I
have no success.

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?
s = "+abc_cde.fgh_jkl\n"
s[1:-1]
'abc_cde.fgh_jkl'
 
B

boris.smirnov

Thank you very much.
I needed this kick. :)
Rg,
Boris


Grant Edwards napísal(a):
Hallo all,

I have tried for a couple of hours to solve my problem with re but I
have no success.

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?
s = "+abc_cde.fgh_jkl\n"
s[1:-1]
'abc_cde.fgh_jkl'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top