{"id":2336,"date":"2022-01-07T17:40:01","date_gmt":"2022-01-07T16:40:01","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=2336"},"modified":"2022-01-07T17:40:01","modified_gmt":"2022-01-07T16:40:01","slug":"a-megis-moho-nem-moho-regex","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2022\/01\/07\/a-megis-moho-nem-moho-regex\/","title":{"rendered":"A m\u00e9gis moh\u00f3 nem moh\u00f3 regex"},"content":{"rendered":"\n<p>A norm\u00e1l regex quantifierek, mint a ?+* moh\u00f3k, azaz, a lehet\u0151 leghosszabb egyez\u00e9st fogj\u00e1k meg.<\/p>\n\n\n\n<p>Azaz, a &#8220;cica kutya l\u00f3&#8221; bemenetre az &#8220;a.+&#8221; regex a &#8220;a kutya l\u00f3&#8221; r\u00e9szt ragadja meg, nem pedig az &#8220;a l\u00f3&#8221;-t, mert moh\u00f3 a +.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"149\" height=\"178\" src=\"https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image.png\" alt=\"\" class=\"wp-image-2337\"\/><\/figure>\n\n\n\n<p>Ha azt akarjuk, hogy ne legyen moh\u00f3, ?-et kell a quantifier ut\u00e1n \u00edrni:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"141\" height=\"176\" src=\"https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-1.png\" alt=\"\" class=\"wp-image-2338\"\/><\/figure>\n\n\n\n<p>\u00cdgy k\u00e9t egyez\u00e9s is van. Eddig ez trivi\u00e1lis.<\/p>\n\n\n\n<p>A gond ott kezd\u0151d\u00f6tt, amikor t\u00f6bb sorban kellett valamit megkeresni. Ilyenkor be lehet kapcsolni a SingleLine m\u00f3dot, \u00e9s ekkor a . egyezik a sorv\u00e9ge karakterekre is (\\r \u00e9s \\n). Norm\u00e1l esetben nem. Ilyenkor l\u00e1tsz\u00f3lag m\u00e1sk\u00e9pp m\u0171k\u00f6dik a nem moh\u00f3 quantifier.<\/p>\n\n\n\n<p>P\u00e9lda sz\u00f6vegesen, ha valaki ki akarja pr\u00f3b\u00e1lni:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nCreateForExcel\\&amp;lt;(\\w+?)\\&gt;.+?Cica\n\nCreateForExcel&amp;lt;Nyau&gt;);\nreturn CreateListExcel(&quot;ccc&quot;, \nCica\n\nCreateForExcel&amp;lt;Vau&gt;);\nreturn CreateListExcel(&quot;kkk&quot;,\nKutya\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"366\" src=\"https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-2.png\" alt=\"\" class=\"wp-image-2340\" srcset=\"https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-2.png 717w, https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-2-600x306.png 600w, https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-2-300x153.png 300w, https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-2-624x319.png 624w\" sizes=\"auto, (max-width: 717px) 100vw, 717px\" \/><\/figure>\n\n\n\n<p>A feladat, hogy a Cica el\u0151tt meg kell tal\u00e1lni a legk\u00f6zelebbi CreateForExcelt, \u00e9s kiszedni a generikus argument \u00e9rt\u00e9k\u00e9t (Nyau). Ez sz\u00e9pen m\u0171k\u00f6dik.<\/p>\n\n\n\n<p>Na, de most j\u00f6n a kutya!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"955\" height=\"505\" src=\"https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-3.png\" alt=\"\" class=\"wp-image-2341\" srcset=\"https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-3.png 955w, https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-3-600x317.png 600w, https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-3-300x159.png 300w, https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-3-768x406.png 768w, https:\/\/soci.hu\/blog\/wp-content\/uploads\/2022\/01\/image-3-624x330.png 624w\" sizes=\"auto, (max-width: 955px) 100vw, 955px\" \/><\/figure>\n\n\n\n<p>L\u00e1that\u00f3, hogy nem a legr\u00f6videbb egyez\u00e9st fogta meg, hanem a leghosszabbat, pedig miden quantifier non gready.<\/p>\n\n\n\n<p>Mi\u00e9rt?<\/p>\n\n\n\n<p>(A regex nem C# elemz\u00e9sre val\u00f3, de h\u00e9be-h\u00f3ba mindenki szeret n\u00e9ha hekkelni.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A norm\u00e1l regex quantifierek, mint a ?+* moh\u00f3k, azaz, a lehet\u0151 leghosszabb egyez\u00e9st fogj\u00e1k meg. Azaz, a &#8220;cica kutya l\u00f3&#8221; bemenetre az&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2336","post","type-post","status-publish","format-standard","hentry","category-szakmai-elet"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=2336"}],"version-history":[{"count":4,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2336\/revisions"}],"predecessor-version":[{"id":2344,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2336\/revisions\/2344"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=2336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=2336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=2336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}