"little turtle" "Python" Regular Expression (ii)

Source: Internet
Author: User

1>>>ImportRE
The meaning of a #| or an expression2>>> Re.search (r"Fish (c| D)","FISHC")3<_sre. Sre_match object; span= (0, 5), match='FISHC'>4>>> Re.search (r"Fish (c| D)","Fishe")5>>> Re.search (r"^FISHC","Fish")6>>> Re.search (r"^FISHC","FISHC DFADF")7<_sre. Sre_match object; span= (0, 5), match='FISHC'>
What does the #^ say begin with?8>>> Re.search (r"^FISHC","I FISHC DFADF")
What does #$ say end with?9>>> Re.search (r"fishc$","I FISHC DFADF")Ten>>> Re.search (r"fishc$","I FISHC DFADFFISHC") one<_sre. Sre_match object; span= (+), match='FISHC'>
#表示查找回车 a>>> Re.search (r"[\ n]","I FISHC dfadffishc\n") -<_sre. Sre_match object; span= (+), match='\ n'>
#[^...] Indicates a lookup except ... Data outside the condition ->>> Re.search (r"[^a-z]","I FISHC dfadffishc\n") the<_sre. Sre_match object; span= (0, 1), match='I'>
#[^...] Indicates a lookup ... Condition of the data
->>> Re.search (r"[a-z^]","I FISHC dfadffishc\n")
-<_sre. Sre_match object; span= (3, 4), match='I'>
->>> Re.findall (r"[a-z^]","I FISHC dfadffishc\n")
+['I','s','h','D','F','a','D','F','I','s','h']
->>> Re.findall (r"[^a-z]","I FISHC dfadffishc\n")
+['I',' ','F','C',' ','F','C','\ n']
a #\1 means repeating once
at>>> Re.search (r"(fishc) \1","FISHCFISHC")
-<_sre. Sre_match object; span= (0, ten), match='FISHCFISHC'>
- #141 is a (decimal ASCII value of 97) value of octal binary
->>> Re.search (r"(fishc) \141","FISHCFISHC")
->>> Re.search (r"(fishc) \141","FISHCFISHCA")
-<_sre. Sre_match object; span= (5, one), match='FISHCA'>
in>>> Re.search (r"(fishc) \060","FISHCFISHCA")
->>> Re.search (r"(fishc) \060","FishCFishC0")
to<_sre. Sre_match object; span= (5, one), match='FishC0'>
+>>> Re.search (r"\.","fishcfishc0.com")
-<_sre. Sre_match object; span= (one, one), match='.'>
the>>> Re.search (r"[.]","fishcfishc0.com")
*<_sre. Sre_match object; span= (one, one), match='.'>
$>>> Re.search (r"c*","fishcfishc0.com")
Panax Notoginseng<_sre. Sre_match object; span= (0, 0), match="'>
- #* indicates repeated unlimited times
the>>> Re.search (r"(fishc) *","fishcfishc0.com")
+<_sre. Sre_match object; span= (0, ten), match='FISHCFISHC'>
a #+ means repeat 1 to infinity
the>>> Re.search (r"(fishc) +","fishcfishc0.com")
+<_sre. Sre_match object; span= (0, ten), match='FISHCFISHC'>
- #? Repeat 0 or 1 times
$>>> Re.search (r"(fishc)?","fishcfishc0.com")
$<_sre. Sre_match object; span= (0, 5), match='FISHC'>
->>> s=""
->>> Re.search (r"<.+>", S)
the<_sre. Sre_match object; span= (0, match=),''>
->>> Re.search (r"<.+?>", S)
Wuyi<_sre. Sre_match object; span= (0, 6), match=''>

"little turtle" "Python" Regular Expression (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.