Regular expression

Jon Clements joncle at googlemail.com
Tue May 18 10:37:22 EDT 2010


On 18 May, 15:32, Back9 <backgoo... at gmail.com> wrote:
> On May 18, 10:09 am, ilvecchio <terenzio.be... at gmail.com> wrote:
>
>
>
> > On May 18, 3:48 pm, Back9 <backgoo... at gmail.com> 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
>
> > Maybe the easy way is something like this:
>
> > m = re.match('(0x)(.*)','0x340x5A0x9B0xBA')
> > m.groups()[1]
>
> > Terenzio
>
> I mean the result should be like this:
> 0x345A9BBA

Something like: re.sub(r'\B(0x)', '', s)


hth, Jon.




More information about the Python-list mailing list