{"id":43781,"date":"2020-07-13T13:50:00","date_gmt":"2020-07-13T13:50:00","guid":{"rendered":"https:\/\/icrowdnewswire.com\/?p=2649334"},"modified":"2020-07-13T13:50:00","modified_gmt":"2020-07-13T13:50:00","slug":"javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own","status":"publish","type":"post","link":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/","title":{"rendered":"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" width=\"233\" height=\"24\" src=\"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" style=\"display: block; margin-bottom: 5px; clear:both;max-width: 100%;\" link_thumbnail=\"\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Copy-of-Copy-of-Copy-of-Copy-of-Copy-of-Copy-of-...-2-1-796x417.png\" alt=\"Javascript regular expressions aren&rsquo;t that daunting &mdash; here&rsquo;s how to design your own\" width=\"678\" height=\"355\" \/><\/p>\n<p>The first time I ever encountered a regular expression was many years ago now, but I still remember my first thoughts on it:<\/p>\n<ol>\n<li>What is this string-like thing?<\/li>\n<li>I don&rsquo;t want to touch it, it looks scary.<\/li>\n<\/ol>\n<p>I don&rsquo;t remember quite what that regex was doing, or how exactly it looked like, but it scared me to death. In hindsight, I now realize that it wasn&rsquo;t actually that scary after all. In face, it was an easy way to solve the problem in hand.&nbsp;But why did I ever feel this way? It&rsquo;s just the awkwardness of the syntax, they certainly look strange, and if you don&rsquo;t know what they are, they look very complicated.<\/p>\n<div class=\"jwplayer-placeholder\">\n<div id=\"jwplayerInlineAd\" class=\"jwplayer jw-reset jw-state-idle jw-stretch-uniform jw-flag-aspect-mode jw-breakpoint-3 jw-floating-dismissible jw-flag-user-inactive\" role=\"application\" aria-label=\"Video Player\" aria-describedby=\"jw-shortcuts-tooltip-explanation\">\n<div class=\"jw-wrapper jw-reset\">\n<div class=\"jw-preview jw-reset\">&nbsp;<\/div>\n<div class=\"jw-controls-backdrop jw-reset\">&nbsp;<\/div>\n<div class=\"jw-title jw-reset-text\" dir=\"auto\">\n<div class=\"jw-title-primary jw-reset-text\">TNW meets Minibrew<\/div>\n<div class=\"jw-title-secondary jw-reset-text\">MiniBrew wants to make it easy for everyone to craft their own beer in their kitchen. But MiniBrew&rsquo;s mission is bigger than producing a machine that automates the brewing process; they&rsquo;re aiming to be a platform for beer brewing. Individuals and breweries alike can upload their best recipes for different types of beers to the platform, and MiniBrew owners all over the globe can download their favorites from there. We visited their canal-side office in the Dutch city of Utrecht, for a chat with their founder.<\/div>\n<\/div>\n<div class=\"jw-overlays jw-reset\">\n<div id=\"jwplayerInlineAd_googima\" class=\"jw-plugin jw-reset jw-plugin-googima\">\n<div id=\"jwplayerInlineAd_ad\" class=\"jw-ads-view\">\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"afs_ads\">&nbsp;<\/div>\n<\/div>\n<\/div>\n<p>My intention here is not to scare you because regex can be simple. But if you don&rsquo;t understand regex just yet, it could look a little daunting, like this example below:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304366 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-2.58.49-PM-1.png\" alt=\"\" width=\"569\" height=\"80\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>In this article, I&rsquo;m going to&nbsp;demystify regular expressions. I&rsquo;ll tell you what they look like, what they&rsquo;re used for, and howyou can design your regular expressions to solve problems.<\/p>\n<h2 id=\"what-are-regular-expressions\">So, first. What are regular expressions?<\/h2>\n<p>Regular expressions are a way to describe patterns in data strings. They have their own syntax, as is they are their own programming language, and there are methods and ways to interact with regular expressions in most (if not all) programming languages.<\/p>\n<p>But what kind of patterns are we talking about? Common examples of regular expressions determine for example if a given string is an email address or a phone number, or they can be used to verify if a password fulfills a certain complexity.<\/p>\n<p>Once you have the pattern, what can you do with the regular expressions?<\/p>\n<ul>\n<li>Validate a string with the pattern.<\/li>\n<li>Search within a string.<\/li>\n<li>Replace substrings in a string.<\/li>\n<li>Extract information from a string.<\/li>\n<\/ul>\n<h2 id=\"working-with-regular-expressions\">Working with regular expressions<\/h2>\n<p>I&rsquo;m also going to cover how to work with regular expressions in JavaScript, though the concepts learned here apply to other languages as well. With that said, in other languages there may be some differences in the way they treat regular expressions.<\/p>\n<p>Let&rsquo;s look at an example that will validate if the string contains the word&nbsp;<code>Hello<\/code>&nbsp;or not.<\/p>\n<p>In JavaScript, there are two ways to find this out:<\/p>\n<ul>\n<li>Constructor<\/li>\n<li>Literal<\/li>\n<\/ul>\n<h2 id=\"constructor\">Constructor<\/h2>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304367 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.03.07-PM.png\" alt=\"\" width=\"556\" height=\"260\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"literal\">Literal<\/h2>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304368 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.03.17-PM.png\" alt=\"\" width=\"557\" height=\"252\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>In both scenarios, the variable&nbsp;<code>regex<\/code>&nbsp;is an object, which exposes different methods we can use to interact with the regular expression. However, the first example has a more familiar look, instancing an object with a&nbsp;<code>string<\/code>&nbsp;as a parameter. In the second scenario things look a bit weird, there&rsquo;s something that resembles a&nbsp;<code>string<\/code>&nbsp;but instead of quotes is wrapped in&nbsp;<code>\/<\/code>. As it turns out both ways represent the same, I personally like the second option, which is very clean, and IDEs or code editors can have syntax highlighting on the regular expression compared to the first scenario where the regular expression pattern is defined as just a string.<\/p>\n<p>So far, our regular expressions have been fairly simple, it&rsquo;s just the exact match on the string&nbsp;<code>Hello<\/code>&nbsp;and it worked perfectly for JavaScript. However the result we obtained can be different for other languages, even though the regular expression is the same. This is because each programming language can define certain defaults or special behaviors in their regular expressions which can vary from one to another. So sorry about that, but that&rsquo;s just how it is. When we build a RegEx though, for the most part, it&nbsp;will be the same in most programming languages. Before you use it somewhere else you will have to test it and adjust it if necessary.<\/p>\n<h2 id=\"different-uses-of-regular-expressions\">Different uses of regular expressions<\/h2>\n<p>When working with regular expressions we&rsquo;re basically working with the RegExp object methods, or with string methods which allow us to interact with regular expressions.<\/p>\n<h2 id=\"regexpprototypetest\">RegExp.prototype.test()<\/h2>\n<p>The&nbsp;<code>test()<\/code>&nbsp;method&nbsp;executes a search for a match between a regular expression and a specified string. Returns&nbsp;<code>true<\/code>&nbsp;or&nbsp;<code>false<\/code>.<\/p>\n<p>Here&rsquo;s an example. First, see if the specified string contains the string&nbsp;<code>foo:<\/code><\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304369 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.03.34-PM.png\" alt=\"\" width=\"556\" height=\"280\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"regexpprototypeexec\">RegExp.prototype.exec()<\/h2>\n<p>The&nbsp;<code>exec()<\/code>&nbsp;method executes a search for a match in a specified string. Returns a result array, or null.<\/p>\n<p><strong>Example<\/strong>: Look for all the instances of&nbsp;<code>foo<\/code>&nbsp;in the given string:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304370 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.04.02-PM.png\" alt=\"\" width=\"557\" height=\"383\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"stringprototypematch\">String.prototype.match()<\/h2>\n<p>The&nbsp;<code>match()<\/code>&nbsp;method&nbsp;retrieves the result of matching a string against a regular expression.<\/p>\n<p><strong>Example<\/strong>: Find all the capital letters on a string:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304371 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.04.19-PM.png\" alt=\"\" width=\"560\" height=\"313\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"stringprototypematchall\">String.prototype.matchAll()<\/h2>\n<p>The&nbsp;<code>matchAll()<\/code>&nbsp;method&nbsp;returns an iterator of all results matching a string against a regular expression, including capturing groups.<\/p>\n<p><strong>Example<\/strong>: Find occurrences of a string in groups:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304372 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.04.38-PM.png\" alt=\"\" width=\"530\" height=\"602\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304373 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.05.09-PM.png\" alt=\"\" width=\"533\" height=\"399\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"stringprototypesearch\">String.prototype.search()<\/h2>\n<p>The&nbsp;<code>search()<\/code>&nbsp;method&nbsp;executes a search for a match between a regular expression and this string object. It returns the index at which the matched happened, or -1 is there is no match.<\/p>\n<p><strong>Example<\/strong>: Find the position of any character that is not a word character or white space:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304374 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.05.25-PM.png\" alt=\"\" width=\"571\" height=\"417\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"stringprototypereplace\">String.prototype.replace()<\/h2>\n<p>The&nbsp;<code>replace()<\/code>&nbsp;method&nbsp;returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match. If the pattern is a string, only the first occurrence will be replaced.<\/p>\n<p>Note that the original string will remain unchanged.<\/p>\n<p><strong>Example<\/strong>: Replace the word dog with monkey:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304375 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.05.44-PM.png\" alt=\"\" width=\"561\" height=\"442\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>Not to be mistaken here, the method replace() uses regular expressions, so even when we pass a string, it will be interpreted as a regular expression and executed as such. Hence the reason why on the second console.log the word dog got replaced only once. But we will cover more on that later.<\/p>\n<h2 id=\"stringprototypereplaceall\">String.prototype.replaceAll()<\/h2>\n<p>The&nbsp;<code>replaceAll()<\/code>&nbsp;method&nbsp;returns a new string with all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match.<\/p>\n<p><strong>Example<\/strong>: Replace the word &lsquo;dog&rsquo; with &lsquo;monkey&rsquo;:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304376 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.06.02-PM.png\" alt=\"\" width=\"563\" height=\"443\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>It&rsquo;s similar to our previous example, but now we replace all the matches. I usually avoid this function as I can always do it with regular expressions and using the replace() function plus is a function that&rsquo;s not supported in all platforms\/browsers.<\/p>\n<h2 id=\"stringprototypesplit\">String.prototype.split()<\/h2>\n<p>The&nbsp;<code>split()<\/code>&nbsp;method&nbsp;divides a String into an ordered set of substrings and puts these substrings into an array, and returns the array.&nbsp; The division is done by searching for a pattern; where the pattern is provided as the first parameter in the method&rsquo;s call.<\/p>\n<p><strong>Example<\/strong>:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304377 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.06.20-PM.png\" alt=\"\" width=\"565\" height=\"264\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"building-regular-expressions\">Building regular expressions<\/h2>\n<p>Now that we know how to work with regular expressions and the different methods that are available to interact with, let&rsquo;s spend some time building regular expressions to match the patterns we want.<\/p>\n<h2 id=\"anchoring\">Anchoring<\/h2>\n<pre><code>\/hello\/\r\n<\/code><\/pre>\n<p>This will match&nbsp;<code>hello<\/code>&nbsp;wherever it was put inside the string. If you want to match strings that start with &lsquo;hello,&rsquo; use the&nbsp;<code>^<\/code>&nbsp;operator:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304378 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.06.38-PM.png\" alt=\"\" width=\"565\" height=\"103\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>If you want to match strings that end with&nbsp;<code>hello<\/code>, use the&nbsp;<code>$<\/code>&nbsp;operator:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304379 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.06.56-PM.png\" alt=\"\" width=\"560\" height=\"99\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>You can also combine them to find exact matches as seen below:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304380 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.07.13-PM.png\" alt=\"\" width=\"553\" height=\"79\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>To find strings with wildcards in the middle you can use&nbsp;<code>.*<\/code>, which matches any character repeated zero or more times:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304381 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.07.27-PM.png\" alt=\"\" width=\"560\" height=\"131\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"match-items-by-character-or-numeric-range\">Match items by character or numeric range<\/h2>\n<p>Once very cool feature of regular expressions is the ability to match by character or numeric range. But, what do I mean by range? Well, it&rsquo;s something that looks like this:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304382 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.07.44-PM.png\" alt=\"\" width=\"557\" height=\"153\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>These type regex patterns will match when at least one of the characters in the range matches:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304383 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.08.02-PM.png\" alt=\"\" width=\"560\" height=\"206\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>You can also combine ranges:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304384 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.08.19-PM.png\" alt=\"\" width=\"558\" height=\"129\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"negating-a-pattern\">Negating a pattern<\/h2>\n<p>We saw that the&nbsp;<code>^<\/code>&nbsp;character&nbsp;at the beginning of a pattern anchors it to the beginning of a string. However when used inside a range, it negates it:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304418 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.44.43-PM.png\" alt=\"\" width=\"569\" height=\"159\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"meta-characters\">Meta-characters<\/h2>\n<p>There are special characters in regular expressions, some of them include:<\/p>\n<ul>\n<li><code>d<\/code>&nbsp;matches any digit, equivalent to&nbsp;[0-9]<\/li>\n<li><code>D<\/code>&nbsp;matches any character that&rsquo;s not a digit, equivalent to&nbsp;[^0-9]<\/li>\n<li><code>w<\/code>&nbsp;matches any alphanumeric character (plus underscore), equivalent to&nbsp;[A-Za-z_0-9]<\/li>\n<li><code>W<\/code>&nbsp;matches any non-alphanumeric character, anything except&nbsp;[^A-Za-z_0-9]<\/li>\n<li><code>s<\/code>&nbsp;matches any whitespace character: spaces, tabs, newlines and Unicode spaces<\/li>\n<li><code>S<\/code>&nbsp;matches any character that&rsquo;s not a whitespace<\/li>\n<li>&nbsp;matches null<\/li>\n<li><code>n<\/code>&nbsp;matches a newline character<\/li>\n<li><code>t<\/code>&nbsp;matches a tab character<\/li>\n<li><code>uXXXX<\/code>&nbsp;matches a&nbsp;unicode&nbsp;character with code XXXX (requires the&nbsp;u&nbsp;flag)<\/li>\n<li>.&nbsp;matches any character that is not a newline char (e.g.&nbsp;n) (unless you use the&nbsp;s&nbsp;flag, explained later on)<\/li>\n<li><code>[^]<\/code>&nbsp;matches any character, including newline characters. It&rsquo;s useful on multiline strings<\/li>\n<li><code>b<\/code>&nbsp;matches a set of characters at the beginning or end of a word<\/li>\n<li><code>B<\/code>&nbsp;matches a set of characters not at the beginning or end of a word<\/li>\n<\/ul>\n<h2 id=\"regular-expression-choices-or\">Regular expression choices (or)<\/h2>\n<p>If you want to search one string or another, use the | operator:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304386 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.09.26-PM.png\" alt=\"\" width=\"562\" height=\"103\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"quantifiers\">Quantifiers<\/h2>\n<p>Quantifiers are special operators, here are some of them:<\/p>\n<p><strong><code>?<\/code>: optional quantifier<\/strong>&nbsp;Imagine you need to find if a string contains one digit in it, just the one, you can do something like:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304387 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.09.46-PM.png\" alt=\"\" width=\"564\" height=\"188\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p><strong><code>+<\/code>:&nbsp; 1 ore more<\/strong>&nbsp;Matches one or more (&gt;=1) items:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304388 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.10.30-PM.png\" alt=\"\" width=\"557\" height=\"179\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p><strong><code>*<\/code>:&nbsp; 0 ore more<\/strong>&nbsp;Matches cero or more (&gt;=0) items:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304389 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.10.44-PM.png\" alt=\"\" width=\"562\" height=\"179\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p><strong><code>{n}<\/code>: fixed number of matches<\/strong>&nbsp;Matches exactly &lsquo;n&rsquo; items:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304390 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.10.59-PM.png\" alt=\"\" width=\"561\" height=\"180\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p><strong><code>{n, m}<\/code>: n to m number of matches<\/strong>&nbsp;Matches between &lsquo;n&rsquo; and &lsquo;m&rsquo; times:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304419 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.46.18-PM.png\" alt=\"\" width=\"554\" height=\"158\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p><code>m<\/code>&nbsp;can also be omitted, in that case, it will match at least &lsquo;n&rsquo; items:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304420 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.46.42-PM.png\" alt=\"\" width=\"563\" height=\"161\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"escaping\">Escaping<\/h2>\n<p>As we saw already, there are certain characters which have a special meaning, but what if we want to match with of those characters? It&rsquo;s possible to escape special characters with, let&rsquo;s see an example:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304393 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.13.09-PM.png\" alt=\"\" width=\"556\" height=\"101\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"groups\">Groups<\/h2>\n<p>Using parentheses, you can create groups of characters:&nbsp;<code>(...)<\/code>:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304394 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.13.12-PM.png\" alt=\"\" width=\"556\" height=\"152\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>You can also use the qualifiers (like the repetition or the optional qualifier) for a group:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304395 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.13.16-PM.png\" alt=\"\" width=\"561\" height=\"130\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>Groups are also very interesting, especially when used with functions like&nbsp;<code>match()<\/code>&nbsp;and&nbsp;<code>exec()<\/code>&nbsp;as we saw before, they can be captured separately:<\/p>\n<p>Example with&nbsp;<code>exec()<\/code>:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304396 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.13.57-PM.png\" alt=\"\" width=\"564\" height=\"397\" data-lazy=\"true\" \/><\/figure>\n<p><code class=\"language-javascript\" data-lang=\"javascript\">&nbsp;<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>Example with&nbsp;<code>match()<\/code>:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304397 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.15.47-PM.png\" alt=\"\" width=\"569\" height=\"314\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"named-capture-groups\">Named capture groups<\/h2>\n<p>With ES2018 it&rsquo;s now possible to assign names to groups, so that working with the results is much easier. Now, take a look at the following example without naming groups:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304398 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.16.04-PM.png\" alt=\"\" width=\"559\" height=\"276\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>Now using named groups:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304399 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.16.19-PM.png\" alt=\"\" width=\"561\" height=\"501\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"flags\">Flags<\/h2>\n<p>As we saw in the constructor example, regular expressions have some flags which change the behavior for the matches:<\/p>\n<ul>\n<li><code>g<\/code>: matches the pattern multiple times<\/li>\n<li><code>i<\/code>: makes the regex case insensitive<\/li>\n<li><code>m<\/code>: enables multiline mode. In this mode,&nbsp;^&nbsp;and&nbsp;$&nbsp;match the start and end of the whole string. Without this, with multiline strings they match the beginning and end of each line.<\/li>\n<li><code>u<\/code>: enables support for unicode (introduced in ES6\/ES2015)<\/li>\n<li><code>s<\/code>: short for&nbsp;single line, it causes the&nbsp;.&nbsp;to match new line characters as well<\/li>\n<\/ul>\n<p>Flags can be combined, and in the case of regex literals they&rsquo;re set at the end of the regex:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304400 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.16.39-PM.png\" alt=\"\" width=\"564\" height=\"88\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>Or using the constructor as a second parameter of the function:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304401 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.16.53-PM.png\" alt=\"\" width=\"561\" height=\"85\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>That was a lot, enough with that, let&rsquo;s see some cool examples:<\/p>\n<h2 id=\"password-strength\">Password strength<\/h2>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304402 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.16.56-PM.png\" alt=\"\" width=\"559\" height=\"100\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>This checks a password&rsquo;s strength, and it&rsquo;s especially useful if you want to build your own password validator. I know this is subjective, as different services may have different needs, but it&rsquo;s a great place to start.<\/p>\n<h2 id=\"validate-email-address\">Validating email address<\/h2>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304403 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.17.20-PM.png\" alt=\"\" width=\"557\" height=\"74\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>This is probably one of the most famous cases for regular expressions, validating email addresses.<\/p>\n<h2 id=\"ip-addresses\">IP Addresses<\/h2>\n<p>V4:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304404 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.17.23-PM.png\" alt=\"\" width=\"561\" height=\"97\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>V6:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304405 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.17.29-PM.png\" alt=\"\" width=\"564\" height=\"337\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"pull-domain-from-url\">Pull domain from URL<\/h2>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304406 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.18.13-PM.png\" alt=\"\" width=\"560\" height=\"381\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"pull-image-source\">Pull image source<\/h2>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304407 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.18.32-PM.png\" alt=\"\" width=\"554\" height=\"401\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<h2 id=\"credit-card-numbers\">Credit card numbers<\/h2>\n<p>&nbsp;<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1304408 lazy lazyLoaded\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/07\/Screen-Shot-2020-07-08-at-3.18.52-PM.png\" alt=\"\" width=\"562\" height=\"120\" data-lazy=\"true\" \/><\/figure>\n<p>&nbsp;<\/p>\n<p>Regular expressions are a very powerful feature, that can be intimidating at first. But once you get the hang of them, they&rsquo;re pretty cool. Today we learnt what they are, how to use them, and how to build them and some cool examples. I hope the next time you see one of them in your projects you don&rsquo;t run away (like I did), and you try to understand it and work with it.<\/p>\n<p class=\"tags\">\n<div><strong>See Campaign: <\/strong><a href=\"https:\/\/thenextweb.com\/syndication\/2020\/07\/11\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\" target=\"_blank\">https:\/\/thenextweb.com\/syndication\/2020\/07\/11\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/<\/a><br \/><b>Contact Information:<\/b><br \/>LIVE CODE STREAM<\/p>\n<p><b>Tags:<\/b><br \/><a href=\"\"><\/a>, <a href=\"https:\/\/icrowdnewswire.com\/category\/news-category\/wire\/\" rel=\"category tag\">Wire<\/a>, <a href=\"https:\/\/icrowdnewswire.com\/category\/global-regions\/united-states\/\" rel=\"category tag\">United States<\/a>, <a href=\"https:\/\/icrowdnewswire.com\/category\/language\/english\/\" rel=\"category tag\">English<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\" alt=\"image\" width=\"400\" height=\"300\" class=\"cwdfimg\" \/><\/div>\n<div>\n<h3>Contact Information:<\/h3>\n<p>LIVE CODE STREAM<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" width=\"233\" height=\"24\" src=\"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png\" alt=\"\">The first time I ever encountered a regular expression was many years ago now, but I still remember my first thoughts on it: What is this string-like thing? I don&rsquo;t want to touch it, it looks scary. I don&rsquo;t remember quite what that regex was doing, or how exactly it looked like, but it scared &hellip; <a href=\"https:\/\/icrowdnewswire.com\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\">Continue reading <span>Javascript regular expressions aren&rsquo;t that daunting &mdash; here&rsquo;s how to design your own<\/span><\/a> <a href=\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":47,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,22,54],"tags":[],"class_list":["post-43781","post","type-post","status-publish","format-standard","hentry","category-english","category-united-states","category-wire"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own - Business<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own - Business\" \/>\n<meta property=\"og:description\" content=\"The first time I ever encountered a regular expression was many years ago now, but I still remember my first thoughts on it: What is this string-like thing? I don&rsquo;t want to touch it, it looks scary. I don&rsquo;t remember quite what that regex was doing, or how exactly it looked like, but it scared &hellip; Continue reading Javascript regular expressions aren&rsquo;t that daunting &mdash; here&rsquo;s how to design your own Continue Reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\" \/>\n<meta property=\"og:site_name\" content=\"Business\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-13T13:50:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png\" \/>\n<meta name=\"author\" content=\"Bilal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bilal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\",\"url\":\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\",\"name\":\"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own - Business\",\"isPartOf\":{\"@id\":\"https:\/\/ipsnews.net\/business\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png\",\"datePublished\":\"2020-07-13T13:50:00+00:00\",\"author\":{\"@id\":\"https:\/\/ipsnews.net\/business\/#\/schema\/person\/70b05bacee6cf8a877350412fae25e20\"},\"breadcrumb\":{\"@id\":\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#primaryimage\",\"url\":\"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png\",\"contentUrl\":\"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ipsnews.net\/business\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ipsnews.net\/business\/#website\",\"url\":\"https:\/\/ipsnews.net\/business\/\",\"name\":\"Business\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ipsnews.net\/business\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ipsnews.net\/business\/#\/schema\/person\/70b05bacee6cf8a877350412fae25e20\",\"name\":\"Bilal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ipsnews.net\/business\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/01d05f3f41cc0f9ca88d2011a983bb3f2e83e3e92e3532188bf201df38d2aea8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/01d05f3f41cc0f9ca88d2011a983bb3f2e83e3e92e3532188bf201df38d2aea8?s=96&d=mm&r=g\",\"caption\":\"Bilal\"},\"sameAs\":[\"https:\/\/icrowdnewswire.com\/fc\"],\"url\":\"https:\/\/ipsnews.net\/business\/author\/bilal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own - Business","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/","og_locale":"en_US","og_type":"article","og_title":"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own - Business","og_description":"The first time I ever encountered a regular expression was many years ago now, but I still remember my first thoughts on it: What is this string-like thing? I don&rsquo;t want to touch it, it looks scary. I don&rsquo;t remember quite what that regex was doing, or how exactly it looked like, but it scared &hellip; Continue reading Javascript regular expressions aren&rsquo;t that daunting &mdash; here&rsquo;s how to design your own Continue Reading &rarr;","og_url":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/","og_site_name":"Business","article_published_time":"2020-07-13T13:50:00+00:00","og_image":[{"url":"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png","type":"","width":"","height":""}],"author":"Bilal","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Bilal","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/","url":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/","name":"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own - Business","isPartOf":{"@id":"https:\/\/ipsnews.net\/business\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#primaryimage"},"image":{"@id":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#primaryimage"},"thumbnailUrl":"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png","datePublished":"2020-07-13T13:50:00+00:00","author":{"@id":"https:\/\/ipsnews.net\/business\/#\/schema\/person\/70b05bacee6cf8a877350412fae25e20"},"breadcrumb":{"@id":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#primaryimage","url":"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png","contentUrl":"https:\/\/icrowdnewswire.com\/wp-content\/uploads\/2020\/06\/4001-logo.png"},{"@type":"BreadcrumbList","@id":"https:\/\/ipsnews.net\/business\/2020\/07\/13\/javascript-regular-expressions-arent-that-daunting-heres-how-to-design-your-own\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ipsnews.net\/business\/"},{"@type":"ListItem","position":2,"name":"Javascript regular expressions aren\u2019t that daunting \u2014 here\u2019s how to design your own"}]},{"@type":"WebSite","@id":"https:\/\/ipsnews.net\/business\/#website","url":"https:\/\/ipsnews.net\/business\/","name":"Business","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ipsnews.net\/business\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ipsnews.net\/business\/#\/schema\/person\/70b05bacee6cf8a877350412fae25e20","name":"Bilal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ipsnews.net\/business\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/01d05f3f41cc0f9ca88d2011a983bb3f2e83e3e92e3532188bf201df38d2aea8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/01d05f3f41cc0f9ca88d2011a983bb3f2e83e3e92e3532188bf201df38d2aea8?s=96&d=mm&r=g","caption":"Bilal"},"sameAs":["https:\/\/icrowdnewswire.com\/fc"],"url":"https:\/\/ipsnews.net\/business\/author\/bilal\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/posts\/43781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/comments?post=43781"}],"version-history":[{"count":1,"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/posts\/43781\/revisions"}],"predecessor-version":[{"id":43782,"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/posts\/43781\/revisions\/43782"}],"wp:attachment":[{"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/media?parent=43781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/categories?post=43781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ipsnews.net\/business\/wp-json\/wp\/v2\/tags?post=43781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}