Seem to be a lot of regular expression questions lately. There is a
neat little RE demonstrator buried down in
Python24/Tools/Scripts/redemo.py, which makes it easy to experiment
with regular expressions and immediately see the effect of changes. It
would be helpful if it were mentioned in the RE d
'''\[(.*?)\]'''
?-> when this char after(*, +, ?, {n}, {n,}, {n,m}), the match pattern
is not greedy
e.g.1
String: 512.16[3][b]]
Pattern:'''\[(.*)\]'''
This will match "[3][b]]"
e.g.2
String: 512.16[3][b]]
Pattern:'''\[(.*)?\]'''
This will match "[3]" and "[b]"
--
http://mail.python.org/mailman
ProvoWallis wrote:
> Hi,
>
> I'm looking for a little advice about regular expressions. I want to
> capture a string of text that falls between an opening squre bracket
> and a closing square bracket (e.g., "[" and "]") but I've run into a
> small problem.
>
> I've been using this: '''\[(.*?)\]''
Hi,
I'm looking for a little advice about regular expressions. I want to
capture a string of text that falls between an opening squre bracket
and a closing square bracket (e.g., "[" and "]") but I've run into a
small problem.
I've been using this: '''\[(.*?)\]''' as my pattern. I was expecting
th