By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,597 Members | 1,547 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,597 IT Pros & Developers. It's quick & easy.

Re: Exact match with regular expression

P: n/a
On Sun, 26 Oct 2008 17:51:29 +0100, Mr.SpOOn wrote:
I'd like to use regular expressions to parse a string and accept only
valid strings. What I mean is the possibility to check if the whole
string matches the regex.

So if I have:
>>>p = re.compile('a*b*')

I can match this: 'aaaaaabbb'
>>>m = p.match('aaaaaabbb')

But I'd like to get None with this: 'aabDDDDb' Instead it matches the
first part:
>>>m = p.match('aabDDDDb')

I know this is the expected behaviour, but I'm sure it should be
possible doing what I said.
Are there other methods I don't know about in the re module?


$ matches the end of a string, or in MULTILINE mode, the end of a line
(right before newline)

Symmetrically, ^ matches the start of a string, or in MULTILINE mode, the
start of a line (including the start of the string)
Oct 26 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.