By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,629 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,629 IT Pros & Developers. It's quick & easy.

extract text from a string

P: n/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?

thank you very much in advance
regards,
boris

Nov 9 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

boris.smir...@gmail.com wrote:
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.

Nov 9 '06 #2

P: n/a
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
Nov 9 '06 #3

P: n/a
On 2006-11-09, bo***********@gmail.com <bo***********@gmail.comwrote:
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'

--
Grant Edwards grante Yow! ... I think I'm
at having an overnight
visi.com sensation right now!!
Nov 9 '06 #4

P: n/a
Thank you very much.
I needed this kick. :)
Rg,
Boris
Grant Edwards napísal(a):
On 2006-11-09, bo***********@gmail.com <bo***********@gmail.comwrote:
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'

--
Grant Edwards grante Yow! ... I think I'm
at having an overnight
visi.com sensation right now!!
Nov 9 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.