Regular expression

Anthra Norell anthra.norell at bluewin.ch
Wed May 19 03:26:17 EDT 2010


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
>
>   
Unless the use of a regular expression is a requirement I'd do it like this:

'0x%s' % s.split ('x', 1)[1].replace ('x', '')

Frederic




More information about the Python-list mailing list