On Dec 18, 4:41 am, tomasz <[EMAIL PROTECTED]> wrote:
> Is there an alternative to it? Am I missing something? Python doesn't
> have special variables $1, $2 (right?) so you must assign the result
> of a match to a variable, to be able to access the groups.
>
> I'd appreciate any hints.
>
Don't us
tomasz <[EMAIL PROTECTED]> wrote:
> Is there an alternative to it? Am I missing something? Python doesn't
> have special variables $1, $2 (right?) so you must assign the result
> of a match to a variable, to be able to access the groups.
Look for repetition in your code and remove it. That will a
tomasz <[EMAIL PROTECTED]> writes:
> here is a piece of pseudo-code (taken from Ruby) that illustrates the
> problem I'd like to solve in Python:
[...]
I asked the very same question in
http://groups.google.com/group/comp.lang.python/browse_frm/thread/3e8da954ff2265e/4deb5631ade8b393
It seems tha
> Define a small function with each test+action, and iterate over them
> until a match is found:
>
> def check1(input):
> match = re.search(pattern1, input)
> if match:
> return input[:match.end(1)]
>
> def check2(input):
> match = re.search(pattern2, input)
> if match:
> return .
On Dec 18, 1:41 pm, tomasz <[EMAIL PROTECTED]> wrote:
> Hi,
>
> here is a piece of pseudo-code (taken from Ruby) that illustrates the
> problem I'd like to solve in Python:
>
> str = 'abc'
> if str =~ /(b)/ # Check if str matches a pattern
> str = $` + $1# Perform some action
> elsif str
On 18 dic, 09:41, tomasz <[EMAIL PROTECTED]> wrote:
> Hi,
>
> here is a piece of pseudo-code (taken from Ruby) that illustrates the
> problem I'd like to solve in Python:
>
> str = 'abc'
> if str =~ /(b)/ # Check if str matches a pattern
> str = $` + $1# Perform some action
> elsif str =
tomasz a écrit :
> Is there an alternative to it? Am I missing something? Python doesn't
> have special variables $1, $2 (right?) so you must assign the result
> of a match to a variable, to be able to access the groups.
>
Hi Thomasz,
See ie :
http://www.regular-expressions.info/python.html [Se
Hi,
here is a piece of pseudo-code (taken from Ruby) that illustrates the
problem I'd like to solve in Python:
str = 'abc'
if str =~ /(b)/ # Check if str matches a pattern
str = $` + $1# Perform some action
elsif str =~ /(a)/ # Check another pattern
str = $1 + $'# Perform some oth