[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-701037-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-701037-en":130,"doc-similar-701037":160},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","regular-expressions-chapter-11-python-for-everybody","Regular Expressions - Chapter 11 - Python for Everybody","","Regular Expressions - Chapter 11 - Python for Everybody explains how regex (regular expressions) provides a concise, flexible way to match text patterns in computing. It introduces regex as a formal language interpreted by a regular-expression processor and frames common benefits: powerful yet cryptic, fun once understood, and a marker-character style language. A quick guide covers core metacharacters like ^, $, ., \\s, \\S, *, *?, +, +?, character classes, ranges, and negated sets, followed by the re module workflow. It also demonstrates using re.search and re.findall to detect matches or extract substrings in text processing.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/regular-expressions-chapter-11-python-for-everybody/701037/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/regular-expressions-chapter-11-python-for-everybody/701037.png","ImageObject",300,407,{"name":42,"@type":43},"Emma Wilson","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-19","2026-11-12",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What is a regular expression (regex) used for?","Question",{"text":62,"@type":63},"A regular expression provides a concise and flexible way to match strings of text using character and pattern rules.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"What do ^ and $ mean in a regex?",{"text":67,"@type":63},"^ matches the beginning of a line, and $ matches the end of the line.",{"name":69,"@type":60,"acceptedAnswer":70},"How do you use regular expressions in Python with the re module?",{"text":71,"@type":63},"Import the library with import re, then use functions like re.search to test whether a string matches a pattern and re.findall to extract matching portions.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},701037,1794522981,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":33,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":79,"read_time":144,"preview_page_count":33,"preview_urls":145},3848291630094,"https://eur-avatar.wpscdn.com/davatar_085a072bc5b1113ac321206ff7593b45","Regular Expressions  \nChapter 11  \nPython for Everybody [www.py4e.com](www.py4e.com)  \nRegular Expressions  \nIn computing, a regular expression, also referred to as “regex” or “regexp”, provides a concise and flexible means for matching strings of text, such as particular characters, words, or patterns of characters . A regular expression is written in a formal language that can be interpreted by a  \nregular expression processor.  \n[http://en.wikipedia.org/wiki/Regular_expression](http://en.wikipedia.org/wiki/Regular_expression)  \nRegular Expressions  \nReally clever “wild card” expressions for matching and parsing strings  \n[http://en.wikipedia.org/wiki/Regular_expression](http://en.wikipedia.org/wiki/Regular_expression)  \nReally smart “Find” or “Search”  \nUnderstanding Regular  \nExpressions  \n• Very powerful and quite cryptic  \n• Fun once you understand them  \n• Regular expressions are a language unto themselves  \n• A language of “marker characters” -programming with characters  \n• It is kind of an “old school” language-compact  \n[http://xkcd.com/208/](http://xkcd.com/208/)  \nRegular Expression Quick Guide  \n^ Matches the beginning of a line  \n$ Matches the end of the line  \n. Matches any character \\s Matches whitespace \\S Matches any non-whitespace character  \n* Repeats a character zero or more times *? Repeats a character zero or more times (non-greedy)+ Repeats a character one or more times +? Repeats a character one or more times (non-greedy)[aeiou] Matches a single character in the listed set [^XYZ] Matches a single character not in the listed set [a-z0-9] The set of characters can include a range ( Indicates where string extraction is to start) Indicates where string extraction is to end  \n[https://www.py4e.com/lectures3/Pythonlearn-11-Regex-Handout.txt](https://www.py4e.com/lectures3/Pythonlearn-11-Regex-Handout.txt)  \nThe Regular Expression  \nModule  \n• Before you can use regular expressions in your program, you must import the library using “import re”  \n• You can use [re.search](re.search) () to see if a string matches a regular expression, similar to using the find() method for strings  \n• You can use re.findall() to extract portions of a string that match your regular expression, similar to a combination of find() and slicing: var[5:10]  \n[Using](Using re.search)[ re.search](Using re.search)() Like find()  \nhand = open('mbox-short .txt') for line in hand:  \nline = line.rstrip()  \nif line.find('From:') >= 0: print(line)  \nimport re  \nhand = open('mbox-short .txt') for line in hand:  \nline = line.rstrip()  \nif [re.search](re.search) ('From:', line) : print(line)  \nUsing [re.search](re.search) () Like  \nstartswith()  \nhand = open('mbox-short .txt') for line in hand:  \nline = line.rstrip()  \nif line.startswith('From:') : print(line)  \nimport re  \nhand = open('mbox-short .txt') for line in hand:  \nline = line.rstrip()  \nif [re.search](re.search) ('^From:', line) : print(line)  \nWe fine-tune what is matched by adding special characters to the string","cbCaiqMayDFEt22R","https://ap.wps.com/l/cbCaiqMayDFEt22R","pdf",366975,34,"English","# Regular Expressions\n## Python for Everybody\n## Regular Expression Quick Guide\n## The Regular Expression Module\n## Using re.search and re.findall","[{\"question\":\"What is a regular expression (regex) used for?\",\"answer\":\"A regular expression provides a concise and flexible way to match strings of text using character and pattern rules.\"},{\"question\":\"What do ^ and $ mean in a regex?\",\"answer\":\"^ matches the beginning of a line, and $ matches the end of the line.\"},{\"question\":\"How do you use regular expressions in Python with the re module?\",\"answer\":\"Import the library with import re, then use functions like re.search to test whether a string matches a pattern and re.findall to extract matching portions.\"}]","Regular Expressions - Chapter 11 - Python for Everybody | PDF",86,[146,150,153,157],{"page_no":22,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/b80a9d7676702c33cb8dddd6405faebb.webp",983,552,{"page_no":26,"url":151,"width":152,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/9955d680dfb8166193c52da135e7f747.webp",982,{"page_no":30,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/11a7f0d740ab28f221e0057d8fe04798.webp",981,551,{"page_no":33,"url":158,"width":159,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/1bd146b4d9a08cd6820d45e940479c59.webp",980,{"list":161,"token":11},[162,168,174,180,186,192,198,204,211,217],{"doc_id":163,"doc_title":164,"file_type":137,"home_preview_img_url":165,"slug":166,"view_count":30,"category_name":29,"create_tm":167},701030,"Regular Expressions - Quick Reference Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230011576998/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=bXfwKbGZ6lz5B8FDWUiPepqAcA0%3D","regular-expressions-quick-reference-guide",1794522969,{"doc_id":169,"doc_title":170,"file_type":137,"home_preview_img_url":171,"slug":172,"view_count":33,"category_name":29,"create_tm":173},701034,"Mastering Regular Expressions - Third Edition","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230012047369/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=O%2B8%2FjjHGraXGPeDUZfbkSlgwhcE%3D","mastering-regular-expressions-third-edition",1794522977,{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":30,"category_name":29,"create_tm":179},701032,"Regular Expression Pocket Reference - Second Edition - Quick syntax and pattern-matching guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230012047365/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=Us74COzsVVElfa0MO9XWzIRgCrs%3D","regular-expression-pocket-reference-second-edition-quick-syntax-and-pattern-matching-guide",1794522974,{"doc_id":181,"doc_title":182,"file_type":137,"home_preview_img_url":183,"slug":184,"view_count":26,"category_name":29,"create_tm":185},726273,"Regular Expressions - Intro to Patterns and Syntax","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230028539473/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=lJS%2Fm7m%2B5tz02hZtoVPf7K1cYxk%3D","regular-expressions-intro-to-patterns-and-syntax",1795211900,{"doc_id":187,"doc_title":188,"file_type":137,"home_preview_img_url":189,"slug":190,"view_count":30,"category_name":29,"create_tm":191},701031,"Regular Expressions: The Complete Tutorial","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230011577006/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=sWGyMgL7NCQRv6x4mw7PtT6iWzw%3D","regular-expressions-the-complete-tutorial",1794522972,{"doc_id":193,"doc_title":194,"file_type":137,"home_preview_img_url":195,"slug":196,"view_count":33,"category_name":29,"create_tm":197},671798,"Python - Visual QuickStart Guide Table of Contents - Chapter 1 to Appendix B","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988403999/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=Z9%2FnsGsxj7s4%2B5WVVwmRoYvmOVs%3D","python-visual-quickstart-guide-table-of-contents-chapter-1-to-appendix-b",1793580658,{"doc_id":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":30,"category_name":29,"create_tm":203},701038,"The Basics of Regular Expressions in Tableau - Inger Bergom & Christina Butler - Northeast Association for Institutional Research Annual Conference 2019","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230012047413/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=SL18nf675oU9%2FIRZT7goNCX9ULY%3D","the-basics-of-regular-expressions-in-tableau-inger-bergom-christina-butler-northeast-association-for-institutional-research-annual-conference-2019",1794522985,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":209,"category_name":29,"create_tm":210},727275,"Python Programming - The Complete Guide to Learn Python for Data Science, AI, Machine Learning, GUI and More - With Practical Exercises and Interview Questions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230028663614/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=GzxsCVWwQBgwbSjjcTleJCwxyIM%3D","python-programming-the-complete-guide-to-learn-python-for-data-science-ai-machine-learning-gui-and-more-with-practical-exercises-and-interview-questions",11,1795232765,{"doc_id":212,"doc_title":213,"file_type":137,"home_preview_img_url":214,"slug":215,"view_count":101,"category_name":29,"create_tm":216},692231,"Python for Non-programmers - A Gentle Introduction - Part 1","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230003011191/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=9Y%2F%2F%2B7umJrUqZHLxuVVKdUs7xCk%3D","python-for-non-programmers-a-gentle-introduction-part-1",1794186380,{"doc_id":218,"doc_title":219,"file_type":137,"home_preview_img_url":220,"slug":221,"view_count":101,"category_name":29,"create_tm":222},692236,"Python Tutorial - Introduction","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230003011327/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=MHyx9h2dhsE4tbxeGRap%2BqzXdTU%3D","python-tutorial-introduction",1794186391]