kb:zapisi:regex_main

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
kb:zapisi:regex_main [2023/08/15 14:18] – [Whitespace character: \s] milanokb:zapisi:regex_main [2023/08/15 14:36] – [ILI operater — | ili []] milano
Line 30: Line 30:
 ===== ILI operater — | ili [] ===== ===== ILI operater — | ili [] =====
  
-''a(b|c)'' odgovara nizu koji ima **a** praćeno sa **b** //ili// **c**+''a(b|c)'' odgovara nizu koji ima **a** praćeno sa **b** //ili// **c** \\
 ''a[bc]'' isto kao i prethodni ''a[bc]'' isto kao i prethodni
  
Line 64: Line 64:
 |\p{Z}|Odgovara svim znakovima za razdvajanje. Ovo uključuje kategorije Zs, Zl i Zp.| |\p{Z}|Odgovara svim znakovima za razdvajanje. Ovo uključuje kategorije Zs, Zl i Zp.|
  
-===== Flags =====+===== Zastave =====
  
-We are learning how to construct a regex but forgetting a fundamental concept: **flags**.+Učimo kako da konstruišemo regularni izraz, ali zaboravljamo osnovni koncept: **zastave**.
  
-A regex usually comes within this form **/abc/**, where the search pattern is delimited by two slash characters (/). \\ +Redovni izraz se obično nalazi u ovom obliku **/abc/**, gde je obrazac pretrage razgraničen sa dve kose crte (/). \\ 
-At the end we can specify a flag with these values (we can also combine them each other):+Na kraju možemo navesti zastavu sa ovim vrednostima (takođe ih možemo kombinovati jedna sa drugom):
  
-''\g''  (globaldoes not return after the first matchrestarting the subsequent searches from the end of the previous match \\ +''\g''  (globalnise ne vraća posle prvog podudaranjaponovo pokreće sledeće pretrage od kraja prethodnog podudaranja \\ 
-''\m''  (multi-linewhen enabled ''^'' and ''$'' will match the start and end of a lineinstead of the whole string \\ +''\m''  (višelinijski)kada je omogućeno ''^'' ''$'' će odgovarati početku i kraju redaumesto celog niza \\ 
-''\i''  (insensitivemakes the whole expression case-insensitive (for instance **/aBc/i**  would match **AbC**) \\+''\i'' (neosetljivočini ceo izraz neosetljivim na velika i mala slova (na primer **/aBc/i** bi odgovaralo **AbC**) \\
  
-====== Intermediate topics ======+====== Međuteme ======
  
-===== Grouping and capturing — () =====+===== Grupisanje i hvatanje — () =====
  
-''a(bc)'' parentheses create a //capturing group// with value **bc** \\ +Zagrade ''a(bc)'' stvaraju //grupu za snimanje// sa vrednošću **bc** \\ 
-''a(?:bc)*****'' using ''?:''  we disable the capturing group **bc** \\ +''a(?:bc)*****'' koristeći ''?:''  onemogućavamo grupu za snimanje **bc** \\ 
-''a(?<foo>bc)'' using ''?<foo>'' we put a name to the group **bc** \\+''a(?<foo>bc)'' koristeći ''?<foo>'' dali smo ime grupi **bc** \\
  
-This operator is very useful when we need to extract information from strings or data using your preferred programming languageAny multiple occurrences captured by several groups will be exposed in the form of a classical arraywe will access their values specifying using an index on the result of the match.+Ovaj operator je veoma koristan kada treba da izvučemo informacije iz nizova ili podataka koristeći željeni programski jezikSvako višestruko pojavljivanje koje uhvati nekoliko grupa biće izloženo u obliku klasičnog nizapristupićemo njihovim vrednostima specificirajući pomoću indeksa na rezultatu podudaranja.
  
-If we choose to put a name to the groups (using ''(?<foo>…)''we will be able to retrieve the group values using the match result like a dictionary where the keys will be the name of each group.+Ako odlučimo da damo ime grupama (koristeći ''(?<foo>…)''), moći ćemo da preuzmemo vrednosti grupe koristeći rezultat podudaranja kao rečnik gde će ključevi biti ime svake grupe .
  
-===== Bracket expressions — [] =====+===== Izrazi zagrade — [] =====
  
-''[abc]'' matches a string that has **either an a or a b or a c** is the **same as a|b|c ** \\ +''[abc]'' podudara se sa nizom koji ima **ili ili ili c** koje je **isto kao a|b|c ** \\ 
-''[a-c]'' same as previous \\+''[a-c]'' isto kao i prethodni \\
 ''[a-fA-F0-9]'' a string that represents **a single hexadecimal digit, case insensitively** \\ ''[a-fA-F0-9]'' a string that represents **a single hexadecimal digit, case insensitively** \\
 ''[0-9]%'' a string that has a character **from 0 to 9 before a % sign** \\ ''[0-9]%'' a string that has a character **from 0 to 9 before a % sign** \\
  • kb/zapisi/regex_main.txt
  • Last modified: 2023/08/16 09:11
  • by milano