PDA

View Full Version : [SOLVED] Get a string within certain characters.



ratmandall
December 23rd, 2008, 02:06 PM
I need a method to do whats in the link below, except in python, I am assuming it isn't that hard.

http://www.dreamincode.net/forums/showtopic30009.htm

Thanks in advanced.

mike_g
December 23rd, 2008, 02:16 PM
If you are dealing with XML you might find a library useful. I havent used this myself, but you could check this (http://www.chilkatsoft.com/python-xml.asp) out.

ratmandall
December 23rd, 2008, 02:18 PM
If you are dealing with XML you might find a library useful. I havent used this myself, but you could check this (http://www.chilkatsoft.com/python-xml.asp) out.

No I am just dealing with a string.
Eg,"Id=212323&"
Pull out what ever is within "Id=" and "&"

escapee
December 23rd, 2008, 02:38 PM
I need a method to do whats in the link below, except in python, I am assuming it isn't that hard.


Take a look at regular expressions (REGEX) if you'd like to do it simply and don't know what's between the 'Id=' and the '&', but both of those substrings are always there.

ghostdog74
December 23rd, 2008, 03:15 PM
No I am just dealing with a string.
Eg,"Id=212323&"
Pull out what ever is within "Id=" and "&"

i am not going to do it for you as its very easy. you can use split() to on "=" and then strip() to strip out the "&". Or if you are certain the "&" will definitely be the last character, you can use index slicing.

ratmandall
December 24th, 2008, 07:57 AM
i am not going to do it for you as its very easy. you can use split() to on "=" and then strip() to strip out the "&". Or if you are certain the "&" will definitely be the last character, you can use index slicing.

:guitar: :)
Thanks, it works for what I need, and will be handy in the future.