IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası
  sohbet

5Beğeni(ler)
  • 2 Post By Alience
  • 3 Post By CesuryureK

Yeni Konu aç Cevapla
 
LinkBack Seçenekler Stil
Alt 11 Kasım 2005, 23:05   #1
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Regex kullanımı




Notlar:
ircforumlari.net için 5-Eylül-2005 tarihinde Alience tarafından yazılmıştır.
Buradaki yazılanlar en az 3 tane yabancı kaynaktan (genelde php kaynakları)
ve kendi deneyimlerimin sonucu mümkün olduğunca basit,kısa ve karşılaştırmalı
ele alınmıştır.

Expression (yani türkçesi ifade) yazıda aranacak kelime cümle ve veya harf olarak kullanıldı
String en basitinden düz cümle demektir :) .

Regex nedir?:
En basitinden ve anlayacağınız şekilde string karşılaştırma,string içi arama işlemini gerçekleştirmemizi sağlayan komut diyebiliriz. Mirc'de aynı işi yapan operatörler var ama regex hem daha hızlıdır hemde çok daha esnek bir yapıda olduğundan büyük kolaylık sağlar şöyleki:
if *deneme* iswm $1- veya if deneme isin $1-
ile
if $regex($1-,deneme) veya if $regex($1-,deneme) == 1
aynıdır.

Regex kullanımı:
Regex'in en basit kullanımı ile mirc help te $regex([name], text, re) olarak açıklandığını biliyoruz.
burada genel operatörler'i anlatmaya çalışacağım. Yazacağım komutlar $regex(bu bir örnektir,bir) şekline olacak bunu siz aliasese veya nerede kullanmak istiyorsanız ona göre ayarlamak zorundasınız şöyleki hemen sonucu görmek isityorsanız en basit yöntem mirc de komut olarak //echo : $regex(bu bir örnektir,bir) yazıp entere basmanız eğer bir yazısı "bu bir örnektir" de varsa ki var 1 değeri döner, eğer bar $regex(bu bir örnektir,bar) yazarsak 0 değeri döner.
Operatörler:
1: Basit kullanım:
Regexin en basit kullanımı yukarıdada bahsedildiği gibi $regex(string,expression) şeklindedir string içinde expression yazılan yerdeki kelime veya cümle varsa 1 olarak döner yoksa 0 olarak döner.
2: "." Herhangi bir karakter operatörü:
expression da "." herhangi bir karakter yerine geçer şöyleki:
$regex(bu bir örnektir,bir) yerine $regex(bu bir örnektir,b.r) yazarsak yine 1 değeri döner anlamıda b ile r arasına bir karakter gelecek ama ne olduğu önemli değil sadece bir karakter gelmesi yeterli.

3: Tekrar operatörleri
3.1: "*" Hiç yok yada birden çok olabilir Operatörü:
Şimdi bu başlıkta ne demeyin "*" aynı başlıktaki işi yapıyor, aranan string konulduğu yerin önündeki harfle devam ediyorsa veya devam etmiyorsa regex 1 olarak döner. kısacası i* yazdıkmı orada sadece i harfi olabilir veya tekrar eder şekilde olabilir (örn: iiiiiiiiiii gibi.) bu durumda 1 değeri döner, veya //echo : $regex(bu br örnektir,b*r) gibi arada birşey olmasa dahi 1 değeri döner. Daha iyi anlamanız için örnekler aşağıda.
Örnekler:
//echo : $regex(bu bir örnektir,bi*)
//echo : $regex(bu br örnektir,b*r)
//echo : $regex(bu br örnektir,ba*r)
//echo : $regex(bu biiiiiiiir örnektir,bi*r)
//echo : $regex(bu biiiiiiiiaaiir örnektir,bi*r)


3.2: "+" Bir tane veya birden çok olabilir operatörü:
"*" operatörünün hemen hemen aynısı ama tek farkı i+ gibi yazdıkmı en az bir i veya birden çok iiiiiiiiiiiiiii gibi devam edeni görmesi ama i harfi olmadımı * operatörü yerine 1 değilde 0 dönmesi (başlıklardan anlaşıldığı üzere * da hiç yok, + da bir veya daha fazla).
farkı ayırabileceğiniz örnekler:
//echo : $regex(bu br örnektir,ba*r)
//echo : $regex(bu br örnektir,ba+r)
//echo : $regex(bu bir örnektir,b*r)
//echo : $regex(bu bir örnektir,b+r)


3.3: "?" Hiçolmayabilir yada birtane olabilir operatörü:
"." operatöründen tek farkı yerine herhangi bir karakter gelme zorunluluğu olmaması.
Farkları anlamanız için örnekler:
$regex(bu bir örnektir,b.r)
$regex(bu bir örnektir,b?r)
$regex(bu br örnektir,b.r)
$regex(bu br örnektir,b?r)


3.4: "{..}" uzunluk operatörü:
tanımlama şekilleri {uzunluk}, {min,max}, {min, }şekillerinde olabilir. Regex'te br{3} gibi belirtiğimiz zaman aranan stringin içinde brrrr gibi br den sonra en az 3 tane son yazılan karakterden olmalı ki regex 1 değeri dönsün. Kısacası + operatörünün hemen hemen aynısı ama farkı tekrar eden sayıların aramasını bizim sınırlandırabilmemiz.
[color=blue]//echo : $regex(bu brr örnektir,br{3})
//echo : $regex(bu brrr örnektir,br{3})
//echo : $regex(bu abrbrbr örnektir,a(br){3}) ;buda br nin grup şeklinde devam etmesi () grup operatörü ne işe yaradığı aşağıda yazıyor.

4: "|" veya Operatörü:
if a == b || a == c dekindeki aynı mantık a b ye eşit olabilir veya a c ye eşit olabilir, regexte $regex(deneme bu bir örnektir,bar|bir) yazarsak "bu bir örnektir" yazısında "bar" yok ama "bir" var ve regex 1 değeri olarak döner.

5: "^" başlama Operatörü:
^ önüne konulan expression aranan stringin ilk kelimesi ise 1 değeri döner, eğer yukarıdaki örneklerdeki gibi "bir" kelimesini ararken $regex(bu bir denemedir,^bir) şeklinde yazarsak 0 değeri döner ama $regex(bu bir denemedir,^bu bir) şeklinde yazarsak 1 değeri döner, Özetle bu* iswm bu bir denemedir ile aynı işlemi yapıyor.

6: "$" bitme Operatörü:
^ operatörü ile aynı olup tek farkı aranan string'in o expression ile bitmesi gereklidir. Özetle $regex(bu bir denemedir,denemedir$) veya $regex(bu bir denemedir,dir$) yazarsak 1 değerleri döner, yani if *dir iswm ile aynıdır.

6: "[[: :]]" Karakter sınıfı Operatörleri:
kullanımları $regex(string,[[:operatör:]])
Operatörleri ve anlamları:
alnum : yazı karakterleri ve sayılar
alpha : sadece yazı karakterleri
blank : space veya tab.
cntrl : kontrol karakterleri (ASCII de 0177 ve 040 tan duşuk karakterler)
digit : sayılar
lower : küçük harf
space : boşluk, $cr (carriage return) , $crlf (yeni satır), tab
upper : büyük harf
xdigit : hexadesimal sayılar: 0--9, a--f, A--F

Örnekler:
//echo - $regex(AAAA23 $+ $cr,[[:space:]])
//echo - $regex(AAAA23,[[:space:]])
//echo - $regex(AAAA23,[[:digit:]])
//echo - $regex(AAAA,[[:digit:]])

vs..

7: "-" Aralık Operatörü:

Belli aralıklari karşılaştırmaya yarar 1-9,a-z,a-c gibi sırasıyla 1 den 9 a kadar, a dan z ye kadar kücük harfler, a dan c ye kadar kücük harfler'i arar.

Örnekler:
//echo - $regex(3,[1-5])
//echo - $regex(5,[1-5])
//echo - $regex(8,[1-5])



8: "()" Grup Operatörü:

Yukarıda bir örnekte bahsetiğim gibi aradığınız bir expression'u gruplamak için kullanılır br* yazarsak sadece r ye göre işlem yapılır, ama (br)* yaparsak br ye göre işlem yapar.


9: Kelime Operatörleri:

\b :
Kelime tam anlamıyla eşitse 1 değeri döner
Örnekler:
$regex(rat,\brat\b)
$regex(arata rat a,\brat\b)
$regex(arata rata,\brat\b)
$regex(arata rata,rat\b)

vs..

\B :
Kelime içeriyorsa 1 değerini döner \b deki gibi space'e gerek yoktur.
$regex(crate,c\Brat\Be)

\s :
Herhangi bir boşluk karakteri varsa 1 değeri döner.
$regex(deneme mesajı,\s)

\S :
\s nin tam tersi boşluk yoksa 1 döner. $regex(deneme,\S)

\w :
Herhangi kelime sayılabilecek karakter içeriyorsa 1 değeri döner.
$regex(deneme,\w)

\W :
\w nin tam tersi.
$regex(bunu dene,\W)

\d :
Herhangi bir sayı varsa 1 değeri döner
$regex(deneme 20,\d)

\D :
Herhangi bir sayı yoksa 1 değeri döner
$regex(deneme 20,\D)



Extra not: regexte \, {, gibi karakterleri aramak için başına \ koymamız gerekli böylece onları operatör değilde karakter olarak görür. Bu 3. gönderişim allahtan hdd yi yedeklerken cd ye kaydetmişim :D.

 
Alıntı ile Cevapla

IRCForumlari.NET Reklamlar
sohbet odaları sohbet odaları Benimmekan Mobil Sohbet
Alt 13 Eylül 2008, 17:17   #2
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




iswm de !iswm yaparsak tersi oluyor .. $regex de bunu nasil saglayabiliriz ?

[box=SpecifiC]!$regex([arguman])[/box]


Konu SpecifiC tarafından (05 Ekim 2008 Saat 13:29 ) değiştirilmiştir.
 
Alıntı ile Cevapla

Alt 04 Ekim 2008, 11:57   #3
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




valla hiçbirşey anlamadım çok karışık pfs :S

 
Alıntı ile Cevapla

Alt 05 Ekim 2008, 23:21   #4
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




Alience zamanında (2005) yılında emek sarf edip yazmış.
Aradan 3 yıl gecti ve konunun daha çok örnekli (Güncel sorunlarla ilgili örneklemeler) bir anlatıma ihtiyacı var... daRkMorGaN'a katılıyorum,yeni bir ders eğitimi bekliyoruz...

 
Alıntı ile Cevapla

Alt 09 Ekim 2008, 04:33   #5
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




Difuzyon Nickli Üyeden Alıntı
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
Alience zamanında (2005) yılında emek sarf edip yazmış.
Aradan 3 yıl gecti ve konunun daha çok örnekli (Güncel sorunlarla ilgili örneklemeler) bir anlatıma ihtiyacı var... daRkMorGaN'a katılıyorum,yeni bir ders eğitimi bekliyoruz...

Daha Geniş ßir Şekilde Regex'in Anlatıldığı ßir Döküman.. Eklenti Kısmına Ekledim İndirip ßakabilirsiniz.

Burdan İndir Bu forumdaki ekleri görübilmek için 25 mesaja sahip olmanız gerekir. Sizin 0 Mesajınız var.
__________________
Şimdi Saat Sensizliğin Ertesi..
 
Alıntı ile Cevapla

Alt 10 Ekim 2008, 21:41   #6
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




CesurYurek son verdiğini indirip açınca daha da beter kafayı yedim regex arayışım sürüyor hala
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.

 
Alıntı ile Cevapla

Alt 11 Ekim 2008, 02:53   #7
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




daRkMorgaN Nickli Üyeden Alıntı
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
CesurYurek son verdiğini indirip açınca daha da beter kafayı yedim regex arayışım sürüyor hala
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.

regex diğer konulara göre daha ağır ama biraz anlamaya başlayınca en zevkli ve kolayı olduğunu farkedeceksiniz.. help.chm'de zaten yeterince bilgi vermemektedir.bu dökümanları iyice kavrayıp pratik yaptıktan sonra yavaş yavaş devamı gelecektir. birgünde okuyupta öğreneceğinizi düşünmüyorum zaman ve emek gerektiren bir konu

__________________
Şimdi Saat Sensizliğin Ertesi..
 
Alıntı ile Cevapla

Alt 15 Kasım 2008, 17:05   #8
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




daRkMorgaN Nickli Üyeden Alıntı
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
CesurYurek son verdiğini indirip açınca daha da beter kafayı yedim regex arayışım sürüyor hala :D

bende bir zamanlar regex'e çok uzak bir insandım Alience'nin regex dökümanını açıp okuduğumda bu regex modülünü yazan bir insanmı hadi o insansa bunu döküman haline sunan kişidemi insan? diye bir düşünce içersinde kalmıştım açıkcası bu ne yav böle demiştim :D tabi daha sonrasında bilirkişi (Alience) ye birkaç soru sordum sağolsun oda cevapladı ama hala regex.chm dosyasından birşey anlamıyordum. şimdi bu muhabbet ile alakası ne diyeceksin şöyle bağlim; Alience'nin regex.chm dosyasından birşey anlamazken onunla bağdaşmış olan mIRC Scripting Regex'ine yakın bir döküman buldum UnrealIRCD Spamfilter Regular Expression (UnrealIRCD Docs) burada regex gördüm ve okudum sonra Alience'nin Regex dökümanına bakınca ne kadar anlaşılır ve anlatılır bir dilde anlattığının farkına vardım. Açıkcası Regex'i öğrenmek çok basittir ama Regex performansını kapmak onu iyice kavramak iyi bir mirc scripting kabiliyeti ister..

Alıntı:
A Regular Expressions
Regular expressions are used in many places in Unreal, including badwords, spamfilter, and aliases. Regular expressions are a very complex tool used for pattern matching. They are sometimes referred to as "regexp" or "regex." Unreal uses the TRE regular expression library for its regex. This library supports some very complex and advanced expressions that may be confusing. The information below will help you understand how regexps work. If you are interested in more technical and detailed information about the regexp syntax used by Unreal, visit the [Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...].

A.1 Literals
Literals are the most basic component of a regexp. Basically, they are characters that are treated as plaintext. For example, the pattern "test" consists of the four literals, "t," "e," "s," and "t." In Unreal, literals are treated as case insensitive, so the previous regex would match "test" as well as "TEST." Any character that is not a "meta character" (discussed in the following sections) is treated as a literal. You can also explicitely make a character a literal by using a backslash (\). For example, the dot (.) is a metacharacter. If you wish to include a literal ., simply use \. and Unreal will treat this as a period. It is also possible that you want to check for a character that is not easily typed, say ASCII character 3 (color). Rather than having to deal with using an IRC client to create this character, you can use a special sequence, the \x. If you type \x3, then it is interpretted as being the ASCII character 3. The number after the \x is represented as hexidecimal and can be in the range from \x0 to \xFF.

A.2 Dot Operator
The dot (.) operator is used to match "any character." It matches a single character that has any value. For example, the regex "a.c" will match "abc," "adc," etc. However, it will not match "abd" because the "a" and "c" are literals that must match exactly.

A.3 Repetition Operators
One of the common mistakes people make with regex is assuming that they work just like wildcards. That is, the * and ? characters will match just like in a wildcard. While these characters do have similar meaning in a regex, they are not exactly the same. Additionaly, regular expressions also support other, more advanced methods of repetition.
The most basic repetition operator is the ? operator. This operator matches 0 or 1 of the previous character. This, "of the previous character," is where the ? in regex differs from a wildcard. In a wildcard, the expression, "a?c" matches an "a" followed by any character (or no character), followed by a "c." In regex it has a different meaning. It matches 0 or 1 of the letter "a" followed by the letter "c." Basically, the ? is modifying the a by specifying how many a's may be present. To emulate the ? in a wildcard, the . operator is used. The regex "a.?c" is equivilent to the previously mentioned wildcard. It matches the letter "a" followed by 0 or 1 of any character (the ? is modifying the .), followed by a "c."
The next repetition operator is the *. Again, this operator is similar to a wildcard. It matches 0 or more of the previous character. Note that this "of the previous character" is something that is characteristic of all repetition operators. The regex "a*c" matches 0 or more a's followed by a "c." For example, "aaaaaac" matches. Once again, to make this work like a wildcard, you would use "a.*c" which will cause the * to modify the . (any character) rather than the "a."
The + operator is very similar to the *. However, instead of matching 0 or more, it matches 1 or more. Basically, "a*c" will match "c" (0 a's followed by a c), where as "a+c" would not. The "a+" states that there must be "at least" 1 a. So "c" does not match but "ac" and "aaaaaaaaac" do.
The most advanced repetition operator is known as a "boundary." A boundary lets you set exact constraints on how many of the previous character must be present. For example, you may want to require exactly 8 a's, or at least 8 a's, or between 3 and 5 a's. The boundary allows you to accomplish all of these. The basic syntax is {M,N} where M is the lower bound, and N is the upper bound. For example, the match between 3 and 5 a's, you would do "a{3,5}". However, you do not have to specify both numbers. If you do "a{8}" it means there must be exactly 8 a's. Therefore, "a{8}" is equivilent to "aaaaaaaa." To specify the "at least" example, you basically create a boundary that only has a lower bound. So for at least 8 a's, you would do "a{8,}".
By default, all of the repetition operators are "greedy." Greediness is a somewhat complex idea. Basically, it means that an operator will match as many characters as it can. This is best explained by an example.
Say we have the following text:
HELLO
And the following regex:
.+L
In this example, you might think that the .+ matches "HE." However, this is incorrect. Because the + is greedy, it matches "HEL." The reason is, it chooses the largest portion of the input text that can be matched while still allowing the entire regex to match. In this example, it chose "HEL" because the only other requirement is that the character after the text matched by .+ must be an "L". Since the text is "HELLO", "HEL" is followed by an "L," and therefore it matches. Sometimes, however, it is useful to make an operator nongreedy. This can be done by adding a ? character after the repetition operator. Modifying the above to, ".+?L" the .+? will now match "HE" rather than "HEL" since it has been placed in a nongreedy state. The ? can be added to any repetition character: ??, *?, +?, {M,N}?.

A.4 Bracket Expressions
Bracket expressions provide a convenient way to do an "or" operator. For example, if you want to say "match an a or a b." The bracket expression gets its name from the fact that it is enclosed in brackets ([]). The basic syntax is that the expression includes a series of characters. These characters are then treated as though there were an "or" between them. As an example, the expression "[abc]" matches an "a," a "b," or a "c." Therefore, the regexp "a[bd]c" matches "abc" and "adc" but not "acc." One very common thing to do is to check for things such as, a letter, or a digit. Rather than having to do, for example, "[0123456789]", the bracket operator supports ranges. Ranges work by specifying the beginning and ending point with a - between them. Therefore, a more simplistic way to test for a digit is to simply do "[0-9]". The same thing can be used on letters, or in fact, any range of ASCII values. If you want to match a letter, simply do "[a-z]" since Unreal is case insensitive, this will match all letters. You can also include multiple ranges in the same expression. To match a letter or a number, "[0-9a-z]". One complication that this creates is that the - is a special character in a bracket expression. To have it match a literal -, the easiest way is to place it as either the first or last character in the expression. For example, "[0-9-]" matches a digit or a -.
To make things even more simple, there are several "character classes" that may be used within a bracket expression. These character classes eliminate the need to define certain ranges. Character classes are written by enclosing their name in :'s. For example, "[0-9]" could also be written as "[:isdigit:]". The list below shows all of the available character classes and what they do:
  • alnum - alphanumeric characters
  • alpha - alphabetic characters
  • blank - blank characters
  • cntrl - control characters
  • digit - decimal digits (0 through 9)
  • graph - all printable characters except space
  • lower - lower-case letters
  • print - printable characters including space
  • punct - printable characters not space or alphanumeric
  • space - white-space characters
  • upper - upper case letters
  • xdigit - hexadecimal digits
One important note about character classes is that they MUST be the only element in the expression. For example, [:isdigit:-] is NOT legal. Instead, you can accomplish this same goal by nesting the expressions, for example, to do the same thing as "[0-9-]" using a character class, you could do "[[:isdigit:]-]". The last feature of the bracket expression is negation. Sometimes it is useful to say "anything except these characters." For example, if you want to check if the character is "not a letter," it is easier to list a-z and say "not these," than it is to list all the non-letters. Bracket expressions allow you to handle this through negation. You negate the expression by specifying a "^" as the first character. For example, "[^a-z]" would match any non-letter. As with the -, if you want to include a literal ^, do not place it in the first position, "[a-z^]". Also, to negate a character class, you must once again use nesting, "[^[:isdigit:]]" would match any non-digit.

A.5 Assertions
Assertions allow you to test for certain conditions that are not representable by character strings, as well as providing shortcuts for some common bracket expressions. The ^ character is referred to as the "left anchor." This character matches the beginning of a string. If you simply specify a regex such as "test", it will match, for example "this is a test" since that string contains "test." But, sometimes it is useful to ensure that the string actually starts with the pattern. This can be done with ^. For example "^test" means that the text must start with "test." Additionally, the $ character is the "right anchor." This character matches the end of the string. So if you were to do "^test$", then the string must be exactly the word "test."
Similar tests also exist for words. All of the other assertions are specified using a \ followed by a specific character. For example, to test for the beginning and ending of a word, you can use \< and \> respectively.
The remaining assertions all come with two forms, a positive and a negative. These assertions are listed below:
  • \b - Word boundary
  • \B - Non-word boundary
  • \d - Digit character (equivalent to [[:digit:]])
  • \D - Non-digit character (equivalent to [^[:digit:]])
  • \s - Space character (equivalent to [[:space:]])
  • \S - Non-space character (equivalent to [^[:space:]])
  • \w - Word character (equivalent to [[:alnum:]_])
  • \W - Non-word character (equivalent to [^[:alnum:]_])

A.6 Alternation
Alternation is a method of saying "or." The alternation operator is the vertical bar (|). For example, if you wanted to say "a or b" you could do "a|b". For normal letters, this could be replaced by a bracket expression, but alternation can also be used with subexpressions (discussed in the next section).
A.7 Subexpressions
Subexpressions are a portion of of a regex that is treated as a single entity. There are two ways to create a subexpression. The two methods differ with regard to "back references," which will be explained later. To declare a subexpression that uses back references, simply enclose it in parentheses (). To create a subexpression that does not use back references, replace the open-parenthesis with, "(?:". For example, "([a-z])" and "(?:[a-z])". The reason subexpressions are useful is you can then apply operators to the expression. All of the repetition operators, for example, that were mentioned as "X or more of the previous character," can also be used for "X or more of the previous subexpression." For example, if you have a regex of "[0-9][a-z][0-9]", to match a digit, followed by a letter, followed by a digit, and then you decided you wanted to match this sequence twice. Normally, you would do, "[0-9][a-z][0-9][0-9][a-z][0-9]". With subexpressions, however, you can simply do "([0-9][a-z][0-9]){2}".
A.8 Back References
Back references allow you to reference the string that matched one of the subexpressions of the regexp. You use a back reference by specifying a backslash (\) followed by a number, 0-9, for example \1. \0 is a special back reference that refers to the entire regexp, rather than a subexpression. Back references are useful when you want to match something that contains the same string twice. For example, say you have a nick!user@host. You know that there is a trojan that uses a nickname and username that matches "[0-9][a-z]{5}", and both the nickname and username are the same. Using "[0-9][a-z]{5}![0-9][a-z]{5}@.+" will not work because it would allow the nickname and username to be different. For example, the nickname could be 1abcde and the username 2fghij. Back references allow you to overcome this limitation. Using, "([0-9][a-z]{5})!\1@.+" will work exactly as expected. This searches for the nickname matching the given subexpressions, then it uses a back reference to say that the username must be the same text. Since you can only have 9 back references, this is the reason why the (?:) notation is useful. It allows you to create a subexpression without wasting a back reference. Additionally, since back reference information does not need to be saved, it is also faster. Because of this, non-back reference subexpressions should be used whenever back references are not needed.

A.9 Case Sensitivity
As was already mentioned, Unreal makes all regexps case insensitive by default. The main reason for this is, there seem to be many more instances where you want case insensitive searching rather than sensitive, for example, if you block the text "
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
you presumably want to block "
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
as well. However, there are instances where you may want case sensitivity, for example, matching for certain trojans. Because of this, a method is provided to dynamically turn case insensitivity on/off. To turn it off, simply use "(?-i)" and to turn it on, "(?i)". For example, "(?-i)[a-z](?i)[a-z]" will match a lowercase letter (case insensitivity is off) followed by either an uppercase or lowercase letter (case insensitivity is on). Additionally, rather than having to always remember to turn the flag back on when you are finished, you can also specify that the flag change should only apply to a subexpression, for example, "(?-i:[a-z])[a-z]" is equivilent to the previous regexp because the -i only applies to the given subexpression.

benim regex kaynağım bu ve regex.chm gerisi ise hayal gücü.

 
Alıntı ile Cevapla

Alt 15 Kasım 2008, 18:15   #9
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Regex kullanımı




XcLusive Nickli Üyeden Alıntı
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
bende bir zamanlar regex'e çok uzak bir insandım Alience'nin regex dökümanını açıp okuduğumda bu regex modülünü yazan bir insanmı hadi o insansa bunu döküman haline sunan kişidemi insan? diye bir düşünce içersinde kalmıştım açıkcası bu ne yav böle demiştim
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
tabi daha sonrasında bilirkişi (Alience) ye birkaç soru sordum sağolsun oda cevapladı ama hala regex.chm dosyasından birşey anlamıyordum. şimdi bu muhabbet ile alakası ne diyeceksin şöyle bağlim; Alience'nin regex.chm dosyasından birşey anlamazken onunla bağdaşmış olan mIRC Scripting Regex'ine yakın bir döküman buldum UnrealIRCD Spamfilter Regular Expression (UnrealIRCD Docs) burada regex gördüm ve okudum sonra Alience'nin Regex dökümanına bakınca ne kadar anlaşılır ve anlatılır bir dilde anlattığının farkına vardım. Açıkcası Regex'i öğrenmek çok basittir ama Regex performansını kapmak onu iyice kavramak iyi bir mirc scripting kabiliyeti ister..

benim regex kaynağım bu ve regex.chm gerisi ise hayal gücü.


haklısın , regex konusunu görmeden önce sadece öğrenilerek kod yazılabilceğini söylerdim fakat performansın da önemli olduğunu regex sayesinde gördüm .

 
Alıntı ile Cevapla

Cevapla

Etiketler
kullanimi, kullanımı, mirc, mirc download, mirc indir, regex


Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir)
 
Seçenekler
Stil

Yetkileriniz
Konu Acma Yetkiniz Yok
Cevap Yazma Yetkiniz Yok
Eklenti Yükleme Yetkiniz Yok
Mesajınızı Değiştirme Yetkiniz Yok

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-Kodu Kapalı
Trackbacks are Kapalı
Pingbacks are Açık
Refbacks are Açık


Benzer Konular
Konu Konuyu Başlatan Forum Cevaplar Son Mesaj
RegeX KoRay mIRC Scripting Sorunları 3 07 Mayıs 2010 21:50
$Regex sensiz-seven mIRC Scripting Programları 0 29 Ekim 2009 12:14
$regex MoRtaL_ mIRC Scripting Sorunları 23 04 Şubat 2008 11:42