{"id":305477,"date":"2020-06-17T09:02:01","date_gmt":"2020-06-17T09:02:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305477"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305477","title":{"rendered":"\u0428\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430 \u043f\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/506994\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/41\/jh\/nl\/41jhnl4mng2wc51n9i_uxqfdo-q.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/dev.to\/emmabostian\/regex-cheat-sheet-2j2a\" rel=\"nofollow\">\u00abRegex Cheat Sheet\u00bb<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Emma Bostian.<\/p>\n<p>  \u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u00abregex\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 .test()<\/p>\n<pre><code class=\"javascript\">const testString = 'My test string' const testRegex = \/string\/ testRegex.test(testString) \/\/ true <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c | \u2014 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0446\u0438\u044e<\/p>\n<pre><code class=\"javascript\">const regex = \/yes|no|maybe\/ <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u043b\u0430\u0433 i<\/p>\n<pre><code class=\"javascript\">const caseInsensitiveRegex = \/ignore case\/i const testString = 'We use the i flag to iGnOrE CasE' caseInsensitiveRegex.test(testString) \/\/ true <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 .match()<\/p>\n<pre><code class=\"javascript\">const match = 'Hello World!'.macth(\/hello\/i) \/\/ 'Hello' <\/code><\/pre>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u043b\u0430\u0433 g<\/p>\n<pre><code class=\"javascript\">const testString = 'Repeat repeat rePeAt' const regexWithAllMatches = \/Repeat\/gi testString.match(regexWithAllMatches) \/\/ ['Repeat', 'repeat', 'rePeAt'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043b\u044e\u0431\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b.<\/p>\n<pre><code class=\"javascript\">const regexWithWildCard = \/.at\/gi const testString = 'cat BAT cupcake fAt mat dog' const allMatchingWords = testString.match(regexWithWildCard) \/\/ ['cat', 'BAT', 'fAt', 'mat'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043e\u0434\u0438\u043d \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0432 [ ] \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0441\u043a\u043e\u043c\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<\/p>\n<pre><code class=\"javascript\">const regexWithCharClass = \/[cfm]at\/g const testString = 'cat fat bat mat' const allMatchingWords = testString.match(regexWithCharClass) \/\/ ['cat', 'fat', 'mat'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0431\u0443\u043a\u0432\u044b \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d [a-z]<\/p>\n<pre><code class=\"javascript\">const regexWithCharRange = \/[a-e]at\/ const catString = 'cat' const batString = 'bat' const fatString = 'fat'  regexWithCharRange.test(catString) \/\/ true regexWithCharRange.test(batString) \/\/ true regexWithCharRange.test(fatString) \/\/ false <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u043b\u0438 \u0431\u0443\u043a\u0432\u044b<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d [a-z0-9]<\/p>\n<pre><code class=\"javascript\">const regexWithLetterAndNumberRange = \/[a-z0-9]\/ig const testString = 'Emma19382' testString.macth(regexWithLetterAndNumberRange) \/\/ true <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b<\/h5>\n<p>  \u0414\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b ^ \u2014 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440<\/p>\n<pre><code class=\"javascript\">const allCharsNotAllowed = \/[^aeiou]\/gi const allCharsOrNumbersNotAllowed = \/^aeiou0-9\/gi <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b +<\/p>\n<pre><code class=\"javascript\">const oneOrMoreAsRegex = \/a+\/gi const oneOrMoreSsRegex = \/s+\/gi const cityInFlorida = 'Tallahassee'  cityInFlorida.match(oneOrMoreAsRegex) \/\/ ['a', 'a', 'a'] cityInFlorida.match(oneOrMoreSsRegex) \/\/ ['ss'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u043e\u043b\u044c \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b *<\/p>\n<pre><code class=\"javascript\">const zeroOrMoreOsRegex = \/hi*\/gi const normalHi = 'hi' const happyHi = 'hiiiiii' const twoHis = 'hiihii' const bye = 'bye'  normalHi.match(zeroOrMoreOsRegex) \/\/ ['hi'] happyHi.match(zeroOrMoreOsRegex) \/\/ ['hiiiiii'] twoHis.match(zeroOrMoreOsRegex) \/\/ ['hii', 'hii'] bye.match(zeroOrMoreOsRegex) \/\/ null <\/code><\/pre>\n<p>  <\/p>\n<h5>\u00ab\u041b\u0435\u043d\u0438\u0432\u044b\u0439\u00bb \u043f\u043e\u0438\u0441\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439<\/h5>\n<p>  \u0418\u0449\u0435\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044e.<br \/>  Regex \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0436\u0430\u0434\u043d\u044b\u043c (\u0438\u0449\u0435\u0442 \u0441\u0430\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0443\u044e \u0443\u0441\u043b\u043e\u0432\u0438\u044e). \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b?<\/p>\n<pre><code class=\"javascript\">const testString = 'catastrophe' const greedyRegex = \/c[a-z]*t\/gi const lazyRegex = \/c[a-z]*?t\/gi  testString.match(greedyRegex) \/\/ ['catast'] testString.match(lazyRegex) \/\/ ['cat'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 (\u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u043a\u0438)<\/h5>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b ^ (\u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 [ ] \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430)<\/p>\n<pre><code class=\"javascript\">const emmaAtFrontOfString = 'Emma likes cats a lot.' const emmaNotAtFrontOfString = 'the cats Emma likes are fluffy' const startingStringRegex = \/^Emma\/  startingStringRegex.test(emmaAtFrontOfString) \/\/ true startingStringRegex.test(emmaNotAtFrontOfString) \/\/ false <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 (\u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0440\u043e\u043a\u0438)<\/h5>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b $<\/p>\n<pre><code class=\"javascript\">const emmaAtBackOfString = 'The cats do not like Emma' const emmaNotAtBackOfString = 'Emma loves the cats' const endingStringRegex = \/Emma$\/  endingStringRegex.test(emmaAtBackOfString) \/\/ true endingStringRegex.test(emmaNotAtBackOfString) \/\/ false <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0432\u0441\u0435 \u0431\u0443\u043a\u0432\u044b \u0438\u043b\u0438 \u0447\u0438\u0441\u043b\u0430<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \\w<\/p>\n<pre><code class=\"javascript\">const longHand = \/[A-za-z0-9_]+\/ const shortHand = \/\\w+\/ const numbers = '42' const myFavouriteColor = 'magenta'  longHand.test(numbers) \/\/ true shortHand.test(numbers) \/\/ true longHand.test(myFavouriteColor) \/\/ true shortHand.test(myFavouriteColor) \/\/ true <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043b\u044e\u0431\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u043a\u0432 \u0438 \u0447\u0438\u0441\u0435\u043b<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \\W<\/p>\n<pre><code class=\"javascript\">const noAlphaNumericCharRegex = \/\\W\/gi const weirdCharacters = '!_$!' const alphaNumericCharacters = 'ab24EF'  noAlphaNumericCharRegex.test(weirdCharacters) \/\/ true noAlphaNumericCharRegex.test(alphaNumericCharacters) \/\/ true <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0447\u0438\u0441\u043b\u0430<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \\d \u0432\u043c\u0435\u0441\u0442\u043e [0-9]<\/p>\n<pre><code class=\"javascript\">const digitsRegex = \/\\d\/g const stringWithDigits = 'My cat eats $20.00 worth of food a week'  stringWithDigits.match(digitsRegex) \/\/ ['2', '0', '0', '0'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043d\u0435 \u0447\u0438\u0441\u043b\u0430<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \\D<\/p>\n<pre><code class=\"javascript\">const nonDigitsRegex = \/\\D\/g const stringWithLetters = '101 degrees'  stringWithLetters.match(nonDigitsRegex) \/\/ [' ', 'd', 'e', 'g', 'r', 'e', 'e', 's'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043f\u0440\u043e\u0431\u0435\u043b\u044b<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \\s<\/p>\n<pre><code class=\"javascript\">const sentenceWithWhitespace = 'I like cats!' const spaceRegex = \/\\s\/g spaceRegex.match(sentenceWithWhitespace) \/\/ [' ', ' '] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043b\u044e\u0431\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \\S<\/p>\n<pre><code class=\"javascript\">const sentenceWithWhitespace = 'C a t' const nonWhitespaceRegex = \/\\S\/g sentenceWithWhitespace.match(nonWhitespaceRegex) \/\/ ['C', 'a', 't'] <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c {\u043e\u0442, \u0434\u043e} \u2014 \u043a\u0432\u0430\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440<\/p>\n<pre><code class=\"javascript\">const regularHi = 'hi' const mediocreHi = 'hiii' const superExcitedHey = 'heeeeyyyyy!!!' const excitedRegex = \/hi{1,4}\/  excitedRegex.test(regularHi) \/\/ true excitedRegex.test(mediocreHi) \/\/ true excitedRegex.test(superExcitedHey) \/\/ false <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c {\u043e\u0442, }<\/p>\n<pre><code class=\"javascript\">const regularHi = 'hi' const mediocreHi = 'hiii' const superExcitedHey = 'heeeeyyyyy!!!' const excitedRegex = \/hi{2,}\/  excitedRegex.test(regularHi) \/\/ false excitedRegex.test(mediocreHi) \/\/ true excitedRegex.test(superExcitedHey) \/\/ false <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c {\u0447\u0438\u0441\u043b\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432}<\/p>\n<pre><code class=\"javascript\">const regularHi = 'hi' const mediocreHi = 'hiii' const superExcitedHey = 'heeeeyyyyy!!!' const excitedRegex = \/hi{2}\/  excitedRegex.test(regularHi) \/\/ false excitedRegex.test(mediocreHi) \/\/ true excitedRegex.test(superExcitedHey) \/\/ false <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u043d\u043e\u043b\u044c \u0438\u043b\u0438 \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>?<\/code> \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430<\/p>\n<pre><code class=\"javascript\">const britishSpelling = 'colour' const americanSpelling = 'Color' const langRegex = \/coloru?r\/i  langRegex.test(britishSpelling) \/\/ true langRegex.test(americanSpelling) \/\/ true <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Regular_Expressions\/Cheatsheet\" rel=\"nofollow\">\u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430 \u043e\u0442 MDN<\/a>.<\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043e\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043e \u043d\u0435 \u0437\u0440\u044f.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/506994\/\"> https:\/\/habr.com\/ru\/post\/506994\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/506994\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/41\/jh\/nl\/41jhnl4mng2wc51n9i_uxqfdo-q.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/dev.to\/emmabostian\/regex-cheat-sheet-2j2a\" rel=\"nofollow\">\u00abRegex Cheat Sheet\u00bb<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Emma Bostian.<\/p>\n<p>  \u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u00abregex\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 .test()<\/p>\n<pre><code class=\"javascript\">const testString = 'My test string' const testRegex = \/string\/ testRegex.test(testString) \/\/ true <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0449\u0435\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c | \u2014 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0446\u0438\u044e<\/p>\n<pre><code class=\"javascript\">const regex = \/yes|no|maybe\/ <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u043b\u0430\u0433 i<\/p>\n<pre><code class=\"javascript\">const caseInsensitiveRegex = \/ignore case\/i const testString = 'We use the i flag to iGnOrE CasE' caseInsensitiveRegex.test(testString) \/\/ true <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 .match()<\/p>\n<pre><code class=\"javascript\">const match = 'Hello World!'.macth(\/hello\/i) \/\/ 'Hello' <\/code><\/pre>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-305477","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=305477"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305477\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}