spir wrote:
Hello,
imagine you need to match such a pattern:
pat : (@@ [charset]* @@) | [charset]*
... where [charset] has to include '@'
My questions are:
* Is there any other way than using a non-greedy form of [charset]* ?
Something like this?
(in pseudo-RE syntax)
"(@@" ( [...@]* "@" [...@] | [...@]* "@" "@"+ [^@)] )* [...@]* "@" "@"+ ")"
to understand, break the above down in pieces:
"(@@" ( A | B )* C
with A: [...@]* "@" [...@]
# lots of chars, then a @, and a non-@
B: [...@]* "@" "@"+ [^@)]
# lots of chars then at least two @, and a non-closing bracket
# (the non-@ at the end is for forcing all @ to be matched in "@"+)
C: [...@]* "@" "@"+ ")"
# lots of chars, then at least two @, and finally a closing bracket
* How, actually, is non-greedy character string matching performed?
That's what I'd like to know too.
(and while we are at it, what about the \b )?
Sincerely,
Albert
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor