[Tutor] regex help

Alan Gauld alan.gauld at btinternet.com
Mon Feb 23 09:48:08 CET 2009


"ish_ling" <ish_ling at yahoo.com> wrote 

>    'a b c<H d e f gH> h<H i j kH>'
> 
> I would like a regex to 

Congratulations on a cclear explanation of what you want. 
With regex questions that is half the battle.

> I have figured out how to do this in a multiple-step process

And there's nothing much wrong with multi step.

> with re.findall() in order to find two strings 
> 
>    ['d e f ', 'i j ']
> 
> I can then use another regex to extract the letters 

But you don't need a regex to do that, it could be a list 
comprehension:

[ch for s in yourList for ch in s if ch != ' ' ]


HTH,


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list