Re: Splitting with Regular Expressions

2005-03-19 Thread qwweeeit
It' s my faute that I have not read more deeply the Library Reference... In any case the time "wasted" in developping small applications to number lines and remove comments, triple quoted strings, multiline instructions etc. has been "useful" to learn the language... Now I already have the single t

Re: Splitting with Regular Expressions

2005-03-18 Thread Fredrik Lundh
"qwweeeit" <[EMAIL PROTECTED]> wrote: > In fact I am implementing a cross-reference tool and working on > python sources, I don't need the '.' as separator in order to capture > variables and commands. if you're parsing Python source code, consider using the tokenize module: http://docs.pyt

Re: Splitting with Regular Expressions

2005-03-18 Thread qwweeeit
I thank you for your help. The more flexible solution (Paul McGuire) is interesting but i don't need such a flexibility. In fact I am implementing a cross-reference tool and working on python sources, I don't need the '.' as separator in order to capture variables and commands. I thank nevertheles

Re: Splitting with Regular Expressions

2005-03-17 Thread Fredrik Lundh
"qwweeeit" <[EMAIL PROTECTED]> wrote: > Splitting with RE has (for me!) misterious behaviour! > > I want to get the words from this string: > s= 'This+(that)= a.string!!!' > > in a list like that ['This', 'that', 'a.string'] > considering "a.string" as a word. print re.findall("[\w.]+", s)

Re: Splitting with Regular Expressions

2005-03-17 Thread Paul McGuire
A pyparsing example may be less mysterious. You can define words to be any group of alphas, or you can define a word to be alphas concatenated by '.'s. scanString is a generator that scans for matches in the input string and returns the matching token list, and the start and end location of the m

Re: Splitting with Regular Expressions

2005-03-17 Thread Thomas Guettler
Am Thu, 17 Mar 2005 06:51:19 -0800 schrieb qwweeeit: > Splitting with RE has (for me!) misterious behaviour! > > I want to get the words from this string: > s= 'This+(that)= a.string!!!' > > in a list like that ['This', 'that', 'a.string'] > considering "a.string" as a word. Hi, try this: re.