{"id":20391,"date":"2019-06-03T13:43:32","date_gmt":"2019-06-03T12:43:32","guid":{"rendered":"http:\/\/codecool.com\/?p=20391"},"modified":"2022-03-01T13:39:34","modified_gmt":"2022-03-01T12:39:34","slug":"wyrazenia-regularne-w-programowaniu","status":"publish","type":"post","link":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/","title":{"rendered":"Wyra\u017cenia regularne w programowaniu"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"20391\" class=\"elementor elementor-20391\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-48e92e4 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"48e92e4\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e1b07af\" data-id=\"e1b07af\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0b71185 elementor-widget elementor-widget-text-editor\" data-id=\"0b71185\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Wyra\u017cenia regularne pozwalaj\u0105 na efektywn\u0105 prac\u0119 z konkretnym formatem znak\u00f3w. Dzi\u0119ki nim \u0142atwo zaprogramowa\u0107 zasady wpisywania kodu pocztowego czy adresu e-mail. Ich dzia\u0142anie opiera si\u0119 na kwantyfikatorach, grupach i zakresach.<\/p><p>RegEx swoje pocz\u0105tki wzi\u0119\u0142o w Perl. Dzi\u015b wyra\u017cenia regularne s\u0105 obecne niemal w ka\u017cdym j\u0119zyku programowania.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3522c0d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3522c0d\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-928dadb\" data-id=\"928dadb\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5c34fe3 elementor-widget elementor-widget-image\" data-id=\"5c34fe3\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"540\" height=\"540\" src=\"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg\" class=\"attachment-large size-large wp-image-20392\" alt=\"\" srcset=\"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg 540w, https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1-300x300.jpg 300w, https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1-150x150.jpg 150w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b675258 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b675258\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b7b9e37\" data-id=\"b7b9e37\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-97e4bae elementor-widget elementor-widget-heading\" data-id=\"97e4bae\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Czym s\u0105 wyra\u017cenia regularne?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e804b22 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e804b22\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6b6a0ba\" data-id=\"6b6a0ba\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-53093d6 elementor-widget elementor-widget-text-editor\" data-id=\"53093d6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Czym s\u0105 wyra\u017cenia regularne? Wyra\u017cenia regularne to opis ci\u0105gu znak\u00f3w, kt\u00f3ry stanowi swego rodzaju wzorzec. Sk\u0142adaj\u0105 si\u0119 one z sekwencji atom\u00f3w, a najprostszy nazywany jest litera\u0142em. Mo\u017ce nim by\u0107 cyfra, litera lub jakikolwiek znak specjalny. Litera\u0142y mo\u017cna pogrupowa\u0107 w nawiasach. W wyra\u017ceniach regularnych istotne s\u0105 jeszcze kwantyfikatory, kt\u00f3re determinuj\u0105 liczb\u0119 wyst\u0105pie\u0144 danego atomu oraz operator alternatywy.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6f1ac8f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6f1ac8f\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a590ffb\" data-id=\"a590ffb\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e6f1792 elementor-widget elementor-widget-heading\" data-id=\"e6f1792\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Proste wyra\u017cenia regularne<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4e030f1 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4e030f1\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6b30b40\" data-id=\"6b30b40\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6d56f31 elementor-widget elementor-widget-text-editor\" data-id=\"6d56f31\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Najprostszym wyra\u017ceniem regularnym jest ci\u0105g znak\u00f3w, np. <b>efghj<\/b>. Je\u015bli tekst, czyli nasz ci\u0105g znak\u00f3w, spe\u0142nia wyra\u017cenie regularne to otrzymamy prawd\u0119. Jakakolwiek manipulacja lub zmiana, dodanie, odj\u0119cie literki w te\u015bcie nie spe\u0142ni dopasowania wyra\u017cenia regularnego.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8878bb0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8878bb0\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-26cf7ce\" data-id=\"26cf7ce\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5fd45ac elementor-widget elementor-widget-heading\" data-id=\"5fd45ac\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Kwantyfikatory<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4c6e6dc elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4c6e6dc\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d7da7c4\" data-id=\"d7da7c4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3de3ccd elementor-widget elementor-widget-text-editor\" data-id=\"3de3ccd\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Dodaj\u0105c kwantyfikator do pierwszej litery, mo\u017cemy otrzyma\u0107 nast\u0119puj\u0105ce wyra\u017cenie regularne: <b>e+fghj<\/b>. Dopasowanie w tym przypadku spe\u0142nia\u0107 b\u0119d\u0105 zar\u00f3wno proste wyra\u017cenia takie, jak <b>efghj<\/b>, jak i <b>eefgh<\/b>j. Niezale\u017cnie od ilo\u015bci zapisanych literek \u201ce\u201d na pocz\u0105tku otrzymamy prawd\u0119.<\/p><p>Korzystaj\u0105c z kwantyfikator\u00f3w, nale\u017cy pami\u0119ta\u0107, \u017ce dotycz\u0105 one wy\u0142\u0105cznie atomu po lewej stronie &#8211; je\u015bli obok atomu sta\u0142aby spacja, to kwantyfikator dotyczy\u0142by w\u0142a\u015bnie niej.<\/p><p>\u00a0<\/p><table><tbody><tr><td>Kwantyfikator<\/td><td>Znaczenie<\/td><td>Przyk\u0142ad<\/td><\/tr><tr><td>+<\/td><td>co najmniej jedno wyst\u0105pienie<\/td><td>e*j -&gt; ej, eej,<\/td><\/tr><tr><td>*<\/td><td>zero lub wi\u0119cej wyst\u0105pie\u0144<\/td><td>e+j -&gt; ej, e, j, eej,<\/td><\/tr><tr><td>?<\/td><td>zero lub jedno wyst\u0105pienie<\/td><td>e?j -&gt; ej, j<\/td><\/tr><tr><td>{n,m}<\/td><td>minimum n i maksymalnie m wyst\u0105pie\u0144<\/td><td>e{2,5}j -&gt; eej, eeej, eeeeej<\/td><\/tr><tr><td>{n,}<\/td><td>minimum n wyst\u0105pie\u0144<\/td><td>e{6,} -&gt; eeeeeej<\/td><\/tr><tr><td>{,n}<\/td><td>maksimum n wyst\u0105pie\u0144<\/td><td>e{,6} -&gt; j, ej, eeej<\/td><\/tr><tr><td>{n}<\/td><td>n wyst\u0105pie\u0144<\/td><td>e{6} -&gt; eeeeeej<\/td><\/tr><\/tbody><\/table>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-bb88af3 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"bb88af3\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-932c4f0\" data-id=\"932c4f0\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f9638da elementor-widget elementor-widget-heading\" data-id=\"f9638da\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Zakresy w wyra\u017ceniach regularnych<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-cf804e9 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"cf804e9\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e416ee0\" data-id=\"e416ee0\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1630802 elementor-widget elementor-widget-text-editor\" data-id=\"1630802\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Pisz\u0105c wyra\u017cenia regularne, warto skorzysta\u0107 z zakres\u00f3w. Pozwalaj\u0105 one okre\u015bli\u0107 liczb\u0119 znak\u00f3w w danym miejscu. Zakresy zapisujemy z u\u017cyciem nawias\u00f3w kwadratowych, w kt\u00f3rych po kolei wymieniamy wszystkie dopuszczalna znaki lub wprowadzamy przedzia\u0142, do kt\u00f3rego definicji przyda si\u0119 my\u015blnik.<\/p><p>\u00a0<\/p><table><tbody><tr><td>Wyra\u017cenie<\/td><td>Opis<\/td><\/tr><tr><td>[efghj]<\/td><td>jedna z liter<\/td><\/tr><tr><td>[e-jE-J]<\/td><td>jedna z liter od e do J, du\u017ca lub ma\u0142a<\/td><\/tr><\/tbody><\/table><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-d112d91 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"d112d91\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d592084\" data-id=\"d592084\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-30269e3 elementor-widget elementor-widget-heading\" data-id=\"30269e3\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Grupy w wyra\u017ceniach regularnych<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b7421a5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b7421a5\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2d1e50d\" data-id=\"2d1e50d\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-fa8b84b elementor-widget elementor-widget-text-editor\" data-id=\"fa8b84b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Dzi\u0119ki grupom w wyra\u017ceniach regularnych mo\u017cna \u0142\u0105czy\u0107 skomplikowane struktury. Do zapisywania grup wykorzystujemy nawiasy.<\/p><p>\u00a0<\/p><table><tbody><tr><td>Wyra\u017cenie<\/td><td>Opis<\/td><\/tr><tr><td>e(fghj)*<\/td><td>litera e lub ci\u0105g podany w nawiasie zero lub wi\u0119cej razy<\/td><\/tr><\/tbody><\/table><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-9df64c2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"9df64c2\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e8ed611\" data-id=\"e8ed611\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d658563 elementor-widget elementor-widget-heading\" data-id=\"d658563\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Przyk\u0142ady wyra\u017ce\u0144 regularnych<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b9ad327 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b9ad327\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-198fa95\" data-id=\"198fa95\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-23cc196 elementor-widget elementor-widget-text-editor\" data-id=\"23cc196\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Wyra\u017cenia regularne mog\u0105 pos\u0142u\u017cy\u0107 do zapisu informacji w konkretnym formacie. Na przyk\u0142ad kod pocztowy sk\u0142ada si\u0119 z sze\u015bciu cyfr. W prawid\u0142owej kolejno\u015bci wyst\u0119puj\u0105 one w formacie: dwie cyfry, my\u015blnik, trzy cyfry. Jest to jednak informacja niezrozumia\u0142a dla komputera, dlatego nale\u017cy j\u0105 zapisa\u0107 z wykorzystaniem wyra\u017cenia regularnego, np.:<\/p><p><b>\\d\\d-\\d\\d\\d <\/b>&#8211; zapis ten jest do\u015b\u0107 prosty, zamiast litery \u201cd\u201d nale\u017cy wstawi\u0107 jedn\u0105 z cyfr<\/p><p>lub<\/p><p><b>[0-9]{2}-[0-9]{3} <\/b>&#8211; w tym przypadku wykorzystali\u015bmy kwantyfikatory oraz zakresy. Nawias kwadratowy m\u00f3wi o cyfrze wyst\u0119puj\u0105cej w przedziale od 0 do 9, natomiast klamra decyduje o liczbie wyst\u0105pie\u0144 danego atomu.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b554b99 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b554b99\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-df914c3\" data-id=\"df914c3\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0ecd50a elementor-widget elementor-widget-heading\" data-id=\"0ecd50a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Jak wykorzysta\u0107 regex w codziennej pracy?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c2d9f73 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"c2d9f73\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b96d30f\" data-id=\"b96d30f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b3ef62a elementor-widget elementor-widget-text-editor\" data-id=\"b3ef62a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Wyra\u017cenia regularne w codziennej pracy pomagaj\u0105 mi\u0119dzy innymi w:<\/p><ul><li>walidacji danych formularzy,<\/li><li>sprawdzania tekstu ze wzorcem &#8211; poprawno\u015bci wpisania tekstu w danym formacie,<\/li><li>odnajdowania wzorca w tek\u015bcie &#8211; listowania zawarto\u015bci danej strony konkretnych wzorc\u00f3w, np. adres\u00f3w e-mail, kod\u00f3w pocztowych czy numer\u00f3w telefon\u00f3w,<\/li><li>poci\u0119cia tekstu na fragmenty &#8211; wyci\u0105ga okre\u015blone w zadania fragmenty wzorc\u00f3w,<\/li><li>zamianie tekstu &#8211; szybka i efektywna zmiana formatowania ci\u0105gu znak\u00f3w na inny.<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c1a66dd elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"c1a66dd\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ff03547\" data-id=\"ff03547\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-010543e elementor-widget elementor-widget-heading\" data-id=\"010543e\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">J\u0119zyki programowania, w kt\u00f3rych wykorzystywane s\u0105 wyra\u017cenia regularne<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-14dde69 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"14dde69\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8095bfd\" data-id=\"8095bfd\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0848a0b elementor-widget elementor-widget-text-editor\" data-id=\"0848a0b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Niemal\u017ce w ka\u017cdym j\u0119zyku programowania wyst\u0119puj\u0105 wyra\u017cenia regularne. Znajduj\u0105 si\u0119 one pod nazwami RegEx lub RegExp. W zale\u017cno\u015bci od stosowanego j\u0119zyka wyra\u017cenia regularne mog\u0105 si\u0119 r\u00f3\u017cni\u0107 od siebie sk\u0142adni\u0105 oraz mo\u017cliwo\u015bciami. Wsp\u00f3lne korzenie RegEx odnajduje w j\u0119zyku Perl, sk\u0105d wi\u0119kszo\u015b\u0107 rozwi\u0105za\u0144 zosta\u0142a skopiowana. Gdzie szuka\u0107 wyra\u017ce\u0144 regularnych w j\u0119zykach programowania?<\/p><ul><li><b>Perl<\/b> \u2013 wyra\u017cenia regularne s\u0105 wbudowane,<\/li><li><b>PHP<\/b> \u2013 w celu interpretacji RegEx wykorzystywana jest biblioteka PCRE,<\/li><li><b>C<\/b> \u2013 podobnie jak w przypadku powy\u017cej, nale\u017cy skorzysta\u0107 z biblioteki PCRE,<\/li><li><a href=\"https:\/\/codecool.com\/pl\/wiedza\/czym-charakteryzuje-sie-jezyk-c-codecool\/\" target=\"_blank\" rel=\"noopener noreferrer\"><b>C++ <\/b><\/a>\u2013 wyra\u017cenia regularne dost\u0119pne w bibliotekach: PCRE, RegEx Boost,<\/li><li><b>Java<\/b> \u2013 wyra\u017cenia regularne s\u0105 wbudowane,<\/li><li><a href=\"https:\/\/codecool.com\/pl\/wiedza\/javascript-gdzie-wykorzystuje-sie-js-codecool-pl\/\" target=\"_blank\" rel=\"noopener noreferrer\"><b>JavaScript<\/b><\/a> \u2013 nale\u017cy skorzysta\u0107 z biblioteki xRegEx,<\/li><li><b>.NET<\/b> \u2013 wyra\u017cenia regularne s\u0105 wbudowane.<\/li><li><strong>Zobacz tak\u017ce:<\/strong><a href=\"https:\/\/codecool.com\/pl\/wiedza\/jakie-sa-jezyki-programowania-codecool-pl\/\" target=\"_blank\" rel=\"noopener noreferrer\"> Popularne j\u0119zyki programowania<\/a><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Wyra\u017cenia regularne pozwalaj\u0105 na efektywn\u0105 prac\u0119 z konkretnym formatem znak\u00f3w. Dzi\u0119ki nim \u0142atwo zaprogramowa\u0107 zasady wpisywania kodu pocztowego czy adresu e-mail. Ich dzia\u0142anie opiera si\u0119 na kwantyfikatorach, grupach i zakresach. RegEx swoje pocz\u0105tki wzi\u0119\u0142o w Perl. Dzi\u015b wyra\u017cenia regularne s\u0105 obecne niemal w ka\u017cdym j\u0119zyku programowania. Czym s\u0105 wyra\u017cenia regularne? Czym s\u0105 wyra\u017cenia regularne? Wyra\u017cenia [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":20392,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[133],"tags":[],"class_list":["post-20391","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wiedza"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v24.4 (Yoast SEO v24.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Wyra\u017cenia regularne w programowaniu - Codecool<\/title>\n<meta name=\"description\" content=\"Wyra\u017cenie regularne jest to spos\u00f3b zapisu, kt\u00f3ry sk\u0142ada si\u0119 ze znak\u00f3w oraz metaznak\u00f3w. S\u0105 cz\u0119sto wykorzystywane w r\u00f3\u017cnych j\u0119zykach programowania.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/\" \/>\n<meta property=\"og:locale\" content=\"pl_PL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wyra\u017cenia regularne w programowaniu\" \/>\n<meta property=\"og:description\" content=\"Wyra\u017cenie regularne jest to spos\u00f3b zapisu, kt\u00f3ry sk\u0142ada si\u0119 ze znak\u00f3w oraz metaznak\u00f3w. S\u0105 cz\u0119sto wykorzystywane w r\u00f3\u017cnych j\u0119zykach programowania.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/\" \/>\n<meta property=\"og:site_name\" content=\"Codecool\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CodecoolOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-03T12:43:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-01T12:39:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"540\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dora Hoffman\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Codecool_global\" \/>\n<meta name=\"twitter:site\" content=\"@Codecool_global\" \/>\n<meta name=\"twitter:label1\" content=\"Napisane przez\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dora Hoffman\" \/>\n\t<meta name=\"twitter:label2\" content=\"Szacowany czas czytania\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minuty\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Wyra\u017cenia regularne w programowaniu - Codecool","description":"Wyra\u017cenie regularne jest to spos\u00f3b zapisu, kt\u00f3ry sk\u0142ada si\u0119 ze znak\u00f3w oraz metaznak\u00f3w. S\u0105 cz\u0119sto wykorzystywane w r\u00f3\u017cnych j\u0119zykach programowania.","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:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/","og_locale":"pl_PL","og_type":"article","og_title":"Wyra\u017cenia regularne w programowaniu","og_description":"Wyra\u017cenie regularne jest to spos\u00f3b zapisu, kt\u00f3ry sk\u0142ada si\u0119 ze znak\u00f3w oraz metaznak\u00f3w. S\u0105 cz\u0119sto wykorzystywane w r\u00f3\u017cnych j\u0119zykach programowania.","og_url":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/","og_site_name":"Codecool","article_publisher":"https:\/\/www.facebook.com\/CodecoolOfficial\/","article_published_time":"2019-06-03T12:43:32+00:00","article_modified_time":"2022-03-01T12:39:34+00:00","og_image":[{"width":540,"height":540,"url":"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg","type":"image\/jpeg"}],"author":"Dora Hoffman","twitter_card":"summary_large_image","twitter_creator":"@Codecool_global","twitter_site":"@Codecool_global","twitter_misc":{"Napisane przez":"Dora Hoffman","Szacowany czas czytania":"3 minuty"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#article","isPartOf":{"@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/"},"author":{"name":"Dora Hoffman","@id":"https:\/\/codecool.com\/pl\/#\/schema\/person\/622e226c942203940586ef2dceca8365"},"headline":"Wyra\u017cenia regularne w programowaniu","datePublished":"2019-06-03T12:43:32+00:00","dateModified":"2022-03-01T12:39:34+00:00","mainEntityOfPage":{"@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/"},"wordCount":816,"commentCount":0,"publisher":{"@id":"https:\/\/codecool.com\/pl\/#organization"},"image":{"@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#primaryimage"},"thumbnailUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg","articleSection":["Wiedza"],"inLanguage":"pl-PL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/","url":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/","name":"Wyra\u017cenia regularne w programowaniu - Codecool","isPartOf":{"@id":"https:\/\/codecool.com\/pl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#primaryimage"},"image":{"@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#primaryimage"},"thumbnailUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg","datePublished":"2019-06-03T12:43:32+00:00","dateModified":"2022-03-01T12:39:34+00:00","description":"Wyra\u017cenie regularne jest to spos\u00f3b zapisu, kt\u00f3ry sk\u0142ada si\u0119 ze znak\u00f3w oraz metaznak\u00f3w. S\u0105 cz\u0119sto wykorzystywane w r\u00f3\u017cnych j\u0119zykach programowania.","breadcrumb":{"@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#breadcrumb"},"inLanguage":"pl-PL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/"]}]},{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#primaryimage","url":"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg","contentUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/15940434_1912878288943063_6270023510219818694_n-540x540-1.jpg","width":540,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/codecool.com\/pl\/wyrazenia-regularne-w-programowaniu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codecool.com\/pl\/"},{"@type":"ListItem","position":2,"name":"Wyra\u017cenia regularne w programowaniu"}]},{"@type":"WebSite","@id":"https:\/\/codecool.com\/pl\/#website","url":"https:\/\/codecool.com\/pl\/","name":"Codecool","description":"Next gen coding school &amp; career hub","publisher":{"@id":"https:\/\/codecool.com\/pl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codecool.com\/pl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pl-PL"},{"@type":"Organization","@id":"https:\/\/codecool.com\/pl\/#organization","name":"Codecool","alternateName":"Codecool","url":"https:\/\/codecool.com\/pl\/","logo":{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/codecool.com\/pl\/#\/schema\/logo\/image\/","url":"https:\/\/codecool.com\/wp-content\/uploads\/2023\/09\/Codecool-logo-app.svg","contentUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2023\/09\/Codecool-logo-app.svg","width":1,"height":1,"caption":"Codecool"},"image":{"@id":"https:\/\/codecool.com\/pl\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CodecoolOfficial\/","https:\/\/x.com\/Codecool_global","https:\/\/www.instagram.com\/codecool_official\/","https:\/\/www.linkedin.com\/school\/codecool\/"]},{"@type":"Person","@id":"https:\/\/codecool.com\/pl\/#\/schema\/person\/622e226c942203940586ef2dceca8365","name":"Dora Hoffman","image":{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/codecool.com\/pl\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/13d568fb246033721321e216b8f5f06457e373d046558ceccec33b2e0dc025bc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/13d568fb246033721321e216b8f5f06457e373d046558ceccec33b2e0dc025bc?s=96&d=mm&r=g","caption":"Dora Hoffman"}}]}},"_links":{"self":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/posts\/20391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/comments?post=20391"}],"version-history":[{"count":0,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/posts\/20391\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/media\/20392"}],"wp:attachment":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/media?parent=20391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/categories?post=20391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/tags?post=20391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}