{"id":14183,"date":"2025-05-29T10:32:41","date_gmt":"2025-05-29T07:32:41","guid":{"rendered":"https:\/\/www.inetmar.com\/blog\/?p=14183"},"modified":"2025-05-29T10:32:41","modified_gmt":"2025-05-29T07:32:41","slug":"regular-expression-nedir-regex-kullanimi-ve-ornekleri","status":"publish","type":"post","link":"https:\/\/www.inetmar.com\/blog\/regular-expression-nedir-regex-kullanimi-ve-ornekleri\/","title":{"rendered":"Regular Expression Nedir? Regex Kullan\u0131m\u0131 ve \u00d6rnekleri"},"content":{"rendered":"<p>Regular Expression (k\u0131saca regex) metin i\u00e7inde belirli kal\u0131plar\u0131 aramak, e\u015fle\u015ftirmek veya d\u00fczenlemek i\u00e7in kullan\u0131lan g\u00fc\u00e7l\u00fc bir ara\u00e7t\u0131r. Programlama d\u00fcnyas\u0131nda veri do\u011frulama, metin ayr\u0131\u015ft\u0131rma ve arama i\u015flemlerinde s\u0131k\u00e7a kullan\u0131l\u0131r. <strong>Regex desenleri<\/strong>, e-posta adreslerini kontrol etmekten, telefon numaralar\u0131n\u0131 bulmaya kadar bir\u00e7ok senaryoda hayat kurtar\u0131r. Peki, <strong>regex nas\u0131l kullan\u0131l\u0131r<\/strong>? Bu makalede, <strong>regular expression \u00f6rnekleri<\/strong> ile regex\u2019in temellerini, kullan\u0131m alanlar\u0131n\u0131 ve <strong>regex programlama<\/strong> tekniklerini ad\u0131m ad\u0131m a\u00e7\u0131klayaca\u011f\u0131m. Kod yazmay\u0131 kolayla\u015ft\u0131ran bu sihirli arac\u0131 ke\u015ffetmeye haz\u0131r m\u0131s\u0131n\u0131z?<\/p>\n<h2>Regular Expression (Regex) Nedir?<\/h2>\n<p><a href=\"https:\/\/www.inetmar.com\/blog\/regex-nedir\/\" target=\"_blank\" rel=\"noopener\">Regex<\/a> metin i\u00e7inde belirli bir deseni tan\u0131mlayan karakter dizileridir. Bu desenler, programlama dillerinde (Python, JavaScript, Java, PHP vb.) metin i\u015fleme g\u00f6revlerini otomatikle\u015ftirmek i\u00e7in kullan\u0131l\u0131r. \u00d6rne\u011fin, bir metinde t\u00fcm e-posta adreslerini bulmak veya bir formdaki giri\u015fin ge\u00e7erli bir telefon numaras\u0131 olup olmad\u0131\u011f\u0131n\u0131 kontrol etmek i\u00e7in regex kullan\u0131l\u0131r. <strong>Regex programlama<\/strong>\u00a0metinle \u00e7al\u0131\u015f\u0131rken h\u0131z ve do\u011fruluk sa\u011flar.<\/p>\n<h2>Regex Neden \u00d6nemlidir?<\/h2>\n<p><strong>Regex desenleri<\/strong>, programc\u0131lar ve veri analistleri i\u00e7in vazge\u00e7ilmezdir. \u0130\u015fte regex\u2019in temel faydalar\u0131:<\/p>\n<ul>\n<li><strong>Veri Do\u011frulama:<\/strong> Kullan\u0131c\u0131 giri\u015flerini (e-posta, \u015fifre, telefon) kontrol eder.<\/li>\n<li><strong>Metin Arama:<\/strong> B\u00fcy\u00fck metinlerde belirli kal\u0131plar\u0131 h\u0131zl\u0131ca bulur.<\/li>\n<li><strong>Metin D\u00fczenleme:<\/strong> Belirli kelimeleri veya ifadeleri de\u011fi\u015ftirir.<\/li>\n<li><strong>Veri Ayr\u0131\u015ft\u0131rma:<\/strong> Log dosyalar\u0131ndan veya HTML\u2019den bilgi \u00e7\u0131kar\u0131r.<\/li>\n<li><strong>Zaman Tasarrufu:<\/strong> Manuel metin i\u015fleme yerine otomatik \u00e7\u00f6z\u00fcmler sunar.<\/li>\n<\/ul>\n<p><strong>Regular expression \u00f6rnekleri<\/strong> ile bu faydalar\u0131 daha iyi anlayaca\u011f\u0131z.<\/p>\n<h2>Regex Nas\u0131l Kullan\u0131l\u0131r?<\/h2>\n<p>Regex \u00e7o\u011fu programlama dilinde yerle\u015fik k\u00fct\u00fcphanelerle veya ara\u00e7larla desteklenir. \u0130\u015fte temel ad\u0131mlar:<\/p>\n<ol>\n<li><strong>Desen Tan\u0131mlama:<\/strong> Aramak istedi\u011finiz kal\u0131b\u0131 bir regex deseni olarak yaz\u0131n (\u00f6rne\u011fin, <code>\\d+<\/code> t\u00fcm say\u0131lar\u0131 bulur).<\/li>\n<li><strong>Programlama Dili Se\u00e7imi:<\/strong> Regex\u2019i kullanmak i\u00e7in dilinize uygun k\u00fct\u00fcphaneyi se\u00e7in (Python\u2019da <code>re<\/code>, JavaScript\u2019te <code>RegExp<\/code>).<\/li>\n<li><strong>Fonksiyon Kullan\u0131m\u0131:<\/strong> E\u015fle\u015ftirme (<code>match<\/code>), arama (<code>search<\/code>) veya de\u011fi\u015ftirme (<code>replace<\/code>) gibi i\u015flemleri uygulay\u0131n.<\/li>\n<li><strong>Test Etme:<\/strong> Regex deseninizi regex101.com gibi ara\u00e7larla test edin.<\/li>\n<\/ol>\n<p><strong>Regex programlama<\/strong> s\u00fcrecinde, desenlerin do\u011fru \u00e7al\u0131\u015ft\u0131\u011f\u0131ndan emin olmak i\u00e7in test etmek \u00f6nemlidir.<\/p>\n<h3>Temel Regex Sembolleri<\/h3>\n<p><strong>Regex desenleri<\/strong>\u00a0\u00f6zel semboller ve karakterlerle olu\u015fturulur. \u0130\u015fte en s\u0131k kullan\u0131lanlar:<\/p>\n<ul>\n<li><code>.<\/code>: Herhangi bir karakter (\u00f6rne\u011fin, <code>a.c<\/code> \u201cabc\u201d veya \u201caxc\u201d ile e\u015fle\u015fir).<\/li>\n<li><code>\\d<\/code>: Herhangi bir rakam (0-9).<\/li>\n<li><code>\\w<\/code>: Harf, rakam veya alt \u00e7izgi (_).<\/li>\n<li><code>\\s<\/code>: Bo\u015fluk karakteri (bo\u015fluk, tab).<\/li>\n<li><code>*<\/code>: 0 veya daha fazla tekrar (\u00f6rne\u011fin, <code>a*<\/code> \u201c\u201d, \u201ca\u201d, \u201caa\u201d ile e\u015fle\u015fir).<\/li>\n<li><code>+<\/code>: 1 veya daha fazla tekrar (\u00f6rne\u011fin, <code>\\d+<\/code> \u201c123\u201d ile e\u015fle\u015fir).<\/li>\n<li><code>?<\/code>: 0 veya 1 tekrar (\u00f6rne\u011fin, <code>colou?r<\/code> \u201ccolor\u201d ve \u201ccolour\u201d ile e\u015fle\u015fir).<\/li>\n<li><code>[]<\/code>: Karakter aral\u0131\u011f\u0131 (\u00f6rne\u011fin, <code>[a-z]<\/code> k\u00fc\u00e7\u00fck harfleri bulur).<\/li>\n<li><code>^<\/code>: Sat\u0131r ba\u015f\u0131 (veya desenin ba\u015f\u0131).<\/li>\n<li><code>$<\/code>: Sat\u0131r sonu.<\/li>\n<\/ul>\n<p>Bu semboller <strong>regular expression \u00f6rnekleri<\/strong> olu\u015ftururken temel yap\u0131 ta\u015flar\u0131d\u0131r.<\/p>\n<h2>Regular Expression \u00d6rnekleri<\/h2>\n<p><strong>Regular expression \u00f6rnekleri<\/strong>\u00a0regex\u2019in pratikte nas\u0131l \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 anlamak i\u00e7in en iyi yoldur. \u0130\u015fte yayg\u0131n senaryolar ve desenler:<\/p>\n<ul>\n<li><strong>E-posta Do\u011frulama:<\/strong> <code>^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$<\/code><br \/>\n\u00d6rnek: \u201ckullanici@ornek.com\u201d ile e\u015fle\u015fir, ancak \u201cyanlis@com\u201d e\u015fle\u015fmez.<\/li>\n<li><strong>Telefon Numaras\u0131 Bulma:<\/strong> <code>\\+?\\d{10,12}<\/code><br \/>\n\u00d6rnek: \u201c+905551234567\u201d veya \u201c05551234567\u201d ile e\u015fle\u015fir.<\/li>\n<li><strong>URL Tespiti:<\/strong> <code>https?:\/\/[\\w.-]+\/\\S*<\/code><br \/>\n\u00d6rnek: \u201chttps:\/\/ornek.com\u201d ile e\u015fle\u015fir.<\/li>\n<li><strong>Tarih Format\u0131:<\/strong> <code>\\d{2}\/\\d{2}\/\\d{4}<\/code><br \/>\n\u00d6rnek: \u201c29\/05\/2025\u201d ile e\u015fle\u015fir.<\/li>\n<li><strong>Metindeki Kelime De\u011fi\u015ftirme:<\/strong> <code>\\bkelime\\b<\/code><br \/>\n\u00d6rnek: \u201ckelime\u201dyi bulur ve de\u011fi\u015ftirebilir.<\/li>\n<\/ul>\n<p>Bu \u00f6rnekler <strong>regex nas\u0131l kullan\u0131l\u0131r<\/strong> sorusuna pratik yan\u0131tlar sunar.<\/p>\n<h2>Regex Kullan\u0131m\u0131 i\u00e7in Pratik \u0130pu\u00e7lar\u0131<\/h2>\n<p><strong>Regex programlama<\/strong> s\u00fcrecini kolayla\u015ft\u0131rmak i\u00e7in \u015fu ipu\u00e7lar\u0131n\u0131 takip edin:<\/p>\n<ul>\n<li><strong>Test Ara\u00e7lar\u0131 Kullan\u0131n:<\/strong> regex101.com veya RegExr gibi ara\u00e7larla desenlerinizi test edin.<\/li>\n<li><strong>Basit Ba\u015flay\u0131n:<\/strong> Karma\u015f\u0131k desenler yerine k\u00fc\u00e7\u00fck par\u00e7alarla \u00e7al\u0131\u015f\u0131n.<\/li>\n<li><strong>A\u00e7\u0131klama Ekleyin:<\/strong> Regex kodunuza yorum ekleyerek anla\u015f\u0131l\u0131r hale getirin (\u00f6rne\u011fin, Python\u2019da <code># E-posta deseni<\/code>).<\/li>\n<li><strong>Hatalardan Ka\u00e7\u0131n\u0131n:<\/strong> \u00c7ok geni\u015f desenler (\u00f6rne\u011fin, <code>.*<\/code>) performans sorunlar\u0131na yol a\u00e7abilir.<\/li>\n<li><strong>\u00d6\u011frenmeye Devam Edin:<\/strong> Regex\u2019in ileri d\u00fczey \u00f6zelliklerini (lookaheads, capturing groups) \u00f6\u011frenerek becerilerinizi geli\u015ftirin.<\/li>\n<\/ul>\n<h2>Regex Kullan\u0131rken Dikkat Edilmesi Gerekenler<\/h2>\n<p><strong>Regular Expression nedir<\/strong> \u00f6\u011frenirken \u015fu noktalara dikkat edin:<\/p>\n<ul>\n<li><strong>Performans:<\/strong> Karma\u015f\u0131k regex desenleri, b\u00fcy\u00fck veri setlerinde yava\u015f \u00e7al\u0131\u015fabilir.<\/li>\n<li><strong>Okunabilirlik:<\/strong> A\u015f\u0131r\u0131 karma\u015f\u0131k desenler, kodu bak\u0131m\u0131 zor hale getirir.<\/li>\n<li><strong>Platform Farkl\u0131l\u0131klar\u0131:<\/strong> Farkl\u0131 dillerde regex motorlar\u0131 (PCRE, ECMAScript) ufak farkl\u0131l\u0131klar g\u00f6sterebilir.<\/li>\n<li><strong>G\u00fcvenlik:<\/strong> Kullan\u0131c\u0131 giri\u015flerini regex ile do\u011frulamazsan\u0131z, g\u00fcvenlik a\u00e7\u0131klar\u0131 (ReDoS) olu\u015fabilir.<\/li>\n<\/ul>\n<h2>Regex\u2019in Pop\u00fcler Kullan\u0131m Alanlar\u0131<\/h2>\n<p><strong>Regex desenleri<\/strong>\u00a0bir\u00e7ok alanda yayg\u0131n olarak kullan\u0131l\u0131r:<\/p>\n<ul>\n<li><strong>Web Geli\u015ftirme:<\/strong> Form do\u011frulamalar\u0131 ve URL y\u00f6nlendirmeleri.<\/li>\n<li><strong>Veri Analizi:<\/strong> Log dosyalar\u0131ndan veya veri tabanlar\u0131ndan bilgi \u00e7\u0131karma.<\/li>\n<li><strong>Metin Edit\u00f6rleri:<\/strong> Visual Studio Code veya Notepad++\u2019ta arama\/de\u011fi\u015ftirme.<\/li>\n<li><strong>Otomasyon:<\/strong> Betiklerle metin i\u015fleme g\u00f6revlerini otomatikle\u015ftirme.<\/li>\n<\/ul>\n<p><strong>Regex nas\u0131l kullan\u0131l\u0131r<\/strong> \u00f6\u011frenmek, bu alanlarda b\u00fcy\u00fck bir avantaj sa\u011flar.<\/p>\n<h2>S\u0131k Sorulan Sorular<\/h2>\n<h3>1. Regular Expression nedir?<\/h3>\n<p>Regex metin i\u00e7inde kal\u0131plar\u0131 aramak ve i\u015flemek i\u00e7in kullan\u0131lan bir desen dilidir.<\/p>\n<h3>2. Regex nas\u0131l \u00f6\u011frenilir?<\/h3>\n<p><strong>Regular expression \u00f6rnekleri<\/strong> ile pratik yaparak ve regex101.com gibi ara\u00e7larla test ederek \u00f6\u011frenilir.<\/p>\n<h3>3. Hangi diller regex destekler?<\/h3>\n<p>Python, JavaScript, Java, PHP, C# gibi \u00e7o\u011fu programlama dili <strong>regex programlama<\/strong> i\u00e7in yerle\u015fik destek sunar.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Regular Expression (k\u0131saca regex) metin i\u00e7inde belirli kal\u0131plar\u0131 aramak, e\u015fle\u015ftirmek veya d\u00fczenlemek i\u00e7in kullan\u0131lan g\u00fc\u00e7l\u00fc bir ara\u00e7t\u0131r. Programlama d\u00fcnyas\u0131nda veri do\u011frulama, metin ayr\u0131\u015ft\u0131rma ve arama i\u015flemlerinde s\u0131k\u00e7a kullan\u0131l\u0131r. Regex desenleri, e-posta adreslerini kontrol etmekten, telefon&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":14186,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-14183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/posts\/14183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/comments?post=14183"}],"version-history":[{"count":2,"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/posts\/14183\/revisions"}],"predecessor-version":[{"id":14185,"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/posts\/14183\/revisions\/14185"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/media\/14186"}],"wp:attachment":[{"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/media?parent=14183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/categories?post=14183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inetmar.com\/blog\/wp-json\/wp\/v2\/tags?post=14183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}