{"id":124999,"date":"2022-05-20T15:27:39","date_gmt":"2022-05-20T15:27:39","guid":{"rendered":"https:\/\/blog.finxter.com\/?p=379866"},"modified":"2022-05-20T15:27:39","modified_gmt":"2022-05-20T15:27:39","slug":"your-python-regex-pattern-doesnt-match-try-this","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/05\/20\/your-python-regex-pattern-doesnt-match-try-this\/","title":{"rendered":"Your Python Regex Pattern Doesn\u2019t Match? Try This!"},"content":{"rendered":"<div class=\"kk-star-ratings kksr-valign-top kksr-align-left \" data-payload=\"{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;379866&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;count&quot;:&quot;1&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\\\/5 - (1 vote)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;}\">\n<div class=\"kksr-stars\">\n<div class=\"kksr-stars-inactive\">\n<div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"kksr-stars-active\" style=\"width: 142.5px;\">\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<div class=\"kksr-legend\"> 5\/5 &#8211; (1 vote) <\/div>\n<\/div>\n<h2>Problem Formulation<\/h2>\n<p>Say, you want to find a <a href=\"https:\/\/blog.finxter.com\/python-regex\/\" data-type=\"post\" data-id=\"6210\" target=\"_blank\" rel=\"noreferrer noopener\">regex<\/a> pattern in a given string. You know the pattern exists in the string. You use the <code>re.match(pattern, string)<\/code> function to find the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex-match\/\" data-type=\"post\" data-id=\"5759\" target=\"_blank\">match object<\/a> where the pattern matches in the string.<\/p>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4ac.png\" alt=\"\ud83d\udcac\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Problem<\/strong>: The Python regular expression pattern is not found in the string. The pattern doesn&#8217;t match anything, and, thus, the match object is <code>None<\/code>. How to fix this?<\/p>\n<p>Here&#8217;s an example in which you&#8217;re searching for the pattern <code>'h[a-z]+'<\/code> which should match the substring <code>'hello'<\/code>. <\/p>\n<p>But it doesn&#8217;t match! <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/26a1.png\" alt=\"\u26a1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"7\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import re my_string = 'hello world'\npattern = re.compile('h[a-z]+') match = re.match(pattern, my_string) if match: print('found!')\nelse: print('not found!')<\/pre>\n<p>Output:<\/p>\n<pre class=\"wp-block-preformatted\"><code>not found!<\/code><\/pre>\n<p>Where is the bug? And how to fix it, so that the pattern matches the substring <code>'hello'<\/code>?<\/p>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Learn More<\/strong>: Improve your regex superpower by studying <em><strong>character classes<\/strong><\/em> used in the example pattern <code>'h[a-z]+'<\/code> by visiting <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-character-set-regex-tutorial\/\" data-type=\"post\" data-id=\"6208\" target=\"_blank\">this tutorial on the Finxter blog<\/a>.<\/p>\n<h2>Solution: Use re.search() instead of re.match()<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">A common reason why your Python regular expression pattern is not matching in a given string is that you mistakenly used <code>re.match(pattern, string)<\/code> instead of <code>re.search(pattern, string)<\/code> or <code>re.findall(pattern, string)<\/code>. The former attempts to match the <code>pattern<\/code> at the beginning of the <code>string<\/code>, whereas the latter two functions attempt to match anywhere in the string.<\/p>\n<p>Here&#8217;s a quick recap of the three regex functions:<\/p>\n<ul>\n<li><code><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex-match\/\" data-type=\"post\" data-id=\"5759\" target=\"_blank\">re.match(pattern, string)<\/a><\/code> returns a match object if the <code>pattern<\/code> matches <em><strong>at the beginning<\/strong><\/em> of the <code>string<\/code>. The match object contains useful information such as the matching groups and the matching positions.<\/li>\n<li><code><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-regex-search\/\" data-type=\"post\" data-id=\"5749\" target=\"_blank\">re.search(pattern, string)<\/a><\/code> matches the first occurrence of the <code>pattern<\/code> in the <code>string<\/code> and returns a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-one-line-regex-match\/\" target=\"_blank\">match <\/a>object.<\/li>\n<li><code><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-re-findall\/\" data-type=\"post\" data-id=\"5729\" target=\"_blank\">re.findall(pattern, string)<\/a><\/code> scans <code>string<\/code> from left to right, searching for all non-overlapping matches of the <code>pattern<\/code>. It returns a list of strings in the matching order when scanning the string from left to right.<\/li>\n<\/ul>\n<p>Thus, the following code uses re.search() to fix our problem:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"7\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import re my_string = 'hello world'\npattern = re.compile('h[a-z]+') match = re.search(pattern, my_string) if match: print('found!')\nelse: print('not found!')<\/pre>\n<p>Output:<\/p>\n<pre class=\"wp-block-preformatted\"><code>found!<\/code><\/pre>\n<p>Finally, the pattern <code>'h[a-z]+'<\/code> does match the string <code>'hello world'<\/code>. <\/p>\n<p>Note that you can also use the re.findall() function if you&#8217;re interested in just the string matches of your pattern (without match object). We&#8217;ll explain all of this &#8212; re.match(), re.search(), re.findall(), and match objects &#8212; in a moment but first, let&#8217;s have a look at the same example with re.findall():<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"7\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import re my_string = 'hello world'\npattern = re.compile('h[a-z]+') match = re.findall(pattern, my_string) print(match)\n# ['hello'] if match: print('found!')\nelse: print('not found!')<\/pre>\n<p>Output:<\/p>\n<pre class=\"wp-block-preformatted\"><code>['hello']\nfound!<\/code><\/pre>\n<h2>Understanding re.match()<\/h2>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Python Regex Match: A Complete Guide to re.match()\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/5d3vQ8N0MJg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p class=\"has-pale-cyan-blue-background-color has-background\">The <code>re.match(pattern, string)<\/code> method returns a match object if the <code>pattern<\/code> matches <em><strong>at the beginning<\/strong><\/em> of the <code>string<\/code>. The match object contains useful information such as the matching groups and the matching positions. An optional argument <code>flags<\/code> allows you to customize the regex engine, for example to ignore capitalization.<\/p>\n<p><strong>Specification<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">re.match(pattern, string, flags=0)<\/pre>\n<p>The <code>re.match()<\/code> method has up to three arguments.<\/p>\n<ul>\n<li><strong><code>pattern<\/code><\/strong>: the regular expression pattern that you want to match.<\/li>\n<li><strong><code>string<\/code><\/strong>: the string which you want to search for the pattern.<\/li>\n<li><strong><code>flags<\/code> <\/strong>(optional argument): a more advanced modifier that allows you to customize the behavior of the function. Want to know <a href=\"https:\/\/blog.finxter.com\/python-regex-flags\/\">how to use those flags? Check out this detailed article<\/a> on the Finxter blog.<\/li>\n<\/ul>\n<p>We&#8217;ll explore them in more detail later. <\/p>\n<p><strong>Return Value:<\/strong><\/p>\n<p>The <code>re.match()<\/code> method returns a match object. You may ask (and rightly so):<\/p>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Learn More<\/strong>: Understanding <code><a href=\"https:\/\/blog.finxter.com\/python-regex-match\/\" data-type=\"post\" data-id=\"5759\" target=\"_blank\" rel=\"noreferrer noopener\">re.match()<\/a><\/code> on the Finxter blog.<\/p>\n<h3>What&#8217;s a Match Object?<\/h3>\n<p>If a regular expression matches a part of your string, there&#8217;s a lot of useful information that comes with it: what&#8217;s the exact position of the match? Which regex groups were matched&#8212;and where? <\/p>\n<p>The <a href=\"https:\/\/docs.python.org\/3\/library\/re.html#match-objects\" target=\"_blank\" rel=\"noreferrer noopener\">match object<\/a> is a simple wrapper for this information. Some regex methods of the re package in Python&#8212;such as <code>search()<\/code>&#8212;automatically create a match object upon the first pattern match.<\/p>\n<p>At this point, you don&#8217;t need to explore the match object in detail. Just know that we can access the start and end positions of the match in the string by calling the methods <code>m.start()<\/code> and <code>m.end()<\/code> on the match object <code>m<\/code>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">>>> m = re.search('h...o', 'hello world')\n>>> m.start()\n0\n>>> m.end()\n5\n>>> 'hello world'[m.start():m.end()] 'hello'<\/pre>\n<p>In the first line, you create a match object m by using the <code>re.search()<\/code> method. The pattern <code>'h...o'<\/code> matches in the string <code>'hello world'<\/code> at start position 0. <\/p>\n<p>You use the start and end position to access the substring that matches the pattern (using the popular <a href=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\">Python technique of slicing<\/a>).<\/p>\n<hr class=\"wp-block-separator\"\/>\n<p>Now that you understood the purpose of the match object, let&#8217;s have a look at the alternative to the <code>re.match()<\/code> function next! <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f680.png\" alt=\"\ud83d\ude80\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<h2>Understanding re.search()<\/h2>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Python Regex re.search() - A Simple Guide with Example\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/Mv2VVpUgypc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p class=\"has-global-color-8-background-color has-background\">The <code>re.search(pattern, string)<\/code> method matches the first occurrence of the <code>pattern<\/code> in the <code>string<\/code> and returns a <a rel=\"noreferrer noopener\" title=\"Python One Line Regex Match\" href=\"https:\/\/blog.finxter.com\/python-one-line-regex-match\/\" target=\"_blank\">match <\/a>object. <\/p>\n<p><strong>Specification<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">re.search(pattern, string, flags=0)<\/pre>\n<p>The <code>re.search()<\/code> method has up to three arguments.<\/p>\n<ul>\n<li><strong><code>pattern<\/code><\/strong>: the regular expression pattern that you want to match.<\/li>\n<li><strong><code>string<\/code><\/strong>: the string which you want to search for the pattern.<\/li>\n<li><strong><code>flags <\/code><\/strong>(optional argument): a more advanced modifier that allows you to customize the behavior of the function. Want to know <a href=\"https:\/\/blog.finxter.com\/python-regex-flags\/\">how to use those flags? Check out this detailed article<\/a> on the Finxter blog.<\/li>\n<\/ul>\n<p>We&#8217;ll explore them in more detail later. <\/p>\n<p><strong>Return Value:<\/strong><\/p>\n<p>The <code>re.search()<\/code> method returns a match object. You may ask (and rightly so):<\/p>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Learn More<\/strong>: Understanding <code><a href=\"https:\/\/blog.finxter.com\/python-regex-search\/\" data-type=\"post\" data-id=\"5749\" target=\"_blank\" rel=\"noreferrer noopener\">re.search()<\/a><\/code> on the Finxter blog.<\/p>\n<h2>Understanding re.findall()<\/h2>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Python Regex Findall()\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/QqUVPaP8fpA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<p class=\"has-pale-cyan-blue-background-color has-background\">The <code>re.findall(pattern, string)<\/code> method scans <code>string<\/code> from <strong>left to right<\/strong>, searching for all <strong>non-overlapping matches<\/strong> of the <code>pattern<\/code>. It returns a <strong>list of strings<\/strong> in the matching order when scanning the string from left to right.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/refindall-1024x576.jpg\" alt=\"re.findall() Visual Explanation\" class=\"wp-image-17238\" width=\"768\" height=\"432\" srcset=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/refindall-scaled.jpg 1024w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/refindall-300x169.jpg 300w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/refindall-768x432.jpg 768w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/refindall-150x84.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p><strong>Specification<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">re.findall(pattern, string, flags=0)<\/pre>\n<p>The <code>re.findall()<\/code> method has up to three arguments.<\/p>\n<ul>\n<li><strong><code>pattern<\/code><\/strong>: the regular expression pattern that you want to match.<\/li>\n<li><strong><code>string<\/code><\/strong>: the string which you want to search for the pattern.<\/li>\n<li><strong><code>flags<\/code> <\/strong>(optional argument): a more advanced modifier that allows you to customize the behavior of the function. Want to know <a href=\"https:\/\/blog.finxter.com\/python-regex-flags\/\">how to use those flags? Check out this detailed article<\/a> on the Finxter blog.<\/li>\n<\/ul>\n<p>We will have a look at each of them in more detail. <\/p>\n<p><strong>Return Value:<\/strong><\/p>\n<p>The <code>re.findall()<\/code> method returns a list of strings. Each string element is a matching substring of the string argument.<\/p>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Learn More<\/strong>: Understanding <code><a href=\"https:\/\/blog.finxter.com\/python-re-findall\/\" data-type=\"post\" data-id=\"5729\">re.findall()<\/a><\/code> on the Finxter blog.<\/p>\n<div class=\"wp-container-1 wp-block-group\">\n<div class=\"wp-block-group__inner-container\">\n<h2><a href=\"https:\/\/academy.finxter.com\/university\/mastering-regular-expressions\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"https:\/\/academy.finxter.com\/university\/mastering-regular-expressions\/\">Python Regex Course<\/a><\/h2>\n<p><strong><em>Google engineers are regular expression masters. <\/em><\/strong>The Google search engine is a massive <em>text-processing engine<\/em> that extracts value from trillions of webpages.\u00a0\u00a0<\/p>\n<p><strong><em>Facebook engineers are regular expression masters.<\/em><\/strong> Social networks like Facebook, WhatsApp, and Instagram connect humans via <em>text messages<\/em>.\u00a0<\/p>\n<p><strong><em>Amazon engineers are regular expression masters. <\/em><\/strong>Ecommerce giants ship products based on <em>textual product descriptions<\/em>.\u00a0\u00a0Regular expressions \u200brule the game \u200bwhen text processing \u200bmeets computer science.\u00a0<\/p>\n<p><em><strong>If you want to become a regular expression master too, check out the<a href=\"https:\/\/academy.finxter.com\/university\/mastering-regular-expressions\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"https:\/\/academy.finxter.com\/university\/mastering-regular-expressions\/\"> most comprehensive Python regex course<\/a> on the planet:<\/strong><\/em><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/academy.finxter.com\/university\/mastering-regular-expressions\/\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"576\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2018\/10\/ClickToPlay-1024x576.jpg\" alt=\"\" class=\"wp-image-19840\" srcset=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2018\/10\/ClickToPlay-scaled.jpg 1024w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2018\/10\/ClickToPlay-300x169.jpg 300w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2018\/10\/ClickToPlay-768x432.jpg 768w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2018\/10\/ClickToPlay-1536x864.jpg 1536w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2018\/10\/ClickToPlay-2048x1152.jpg 2048w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2018\/10\/ClickToPlay-150x84.jpg 150w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<hr class=\"wp-block-separator\"\/>\n<p>Now, this was a lot of theory! Let&#8217;s get some practice.<\/p>\n<p>In my Python freelancer bootcamp, I&#8217;ll train you on how to create yourself a new success skill as a Python freelancer with the potential of earning six figures online. <\/p>\n<p>The next recession is coming for sure, and you want to be able to create your own economy so that you can take care of your loved ones.<\/p>\n<p><a rel=\"noreferrer noopener\" aria-label=\"Check out my free webinar now. (opens in a new tab)\" href=\"https:\/\/blog.finxter.com\/webinar-freelancer\/\" target=\"_blank\">Check out my free &#8220;Python Freelancer&#8221; webinar now!<\/a><\/p>\n<p><strong>Join 20,000+ ambitious coders for free!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>5\/5 &#8211; (1 vote) Problem Formulation Say, you want to find a regex pattern in a given string. You know the pattern exists in the string. You use the re.match(pattern, string) function to find the match object where the pattern matches in the string. Problem: The Python regular expression pattern is not found in the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[857],"tags":[73,468,528],"class_list":["post-124999","post","type-post","status-publish","format-standard","hentry","category-python-tut","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=124999"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124999\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=124999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=124999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=124999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}