简体   繁体   中英

Python Regular Expressions Re.Search

I am having issues figuring out what this regular expression means:

import re
if re.search('^(0*)$','010'):
    print 'match'
else:
    print 'no match'

I'm mainly confused about the 0* in the brackets, what does the 0* mean? Can anyone please help? I'm just starting to learn more about regular expressions, and I know what the other symbols in the code mean. The output is : "no match".

Hope someone can help.

Thanks everyone!

0* Matches on Zero or more 0. ^ and $ says that the Wohle String should Match and Not only partial.

Simple regex Basics with some examples: http://www.rexegg.com/regex-quickstart.html

Sorry just for pasting a link, its a pain to write them all down :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM