Regular expression

Terry Reedy tjreedy at udel.edu
Tue May 18 13:11:42 EDT 2010


On 5/18/2010 10:40 AM, J. Cliff Dyer wrote:
> Don't use regular expressions for that.
>
> s = '0x340x5A0x9B0xBA'
> return '0x' + ''.join(s.split('0x'))

or
 >>> '0x'+s[2:].replace('0x','')
'0x345A9BBA'

Take your pick, you should learn and understand both.

> On Tue, 2010-05-18 at 06:48 -0700, Back9 wrote:
>> Hi,
>>
>> I have a string like this:
>> 0x340x5A0x9B0xBA
>> I want to extract 0x from the string but the first one.
>>
>> How I can use re for this case?
>>
>> The string size will vary.
>>
>> TIA
>>
>
>





More information about the Python-list mailing list