Regex Regular Cro
Regex Regular Cro
Regex Regular Cro
Regular Expressions Quantifiers * + ? {3} {3,} {3,5} 0 ili vie 1 ili vie 0 ili 1 tono 3 3 ili vie 3, 4 ili 5
Regular Expressions Groups and Ranges . (a|b) (...) (?:...) [abc] [^abc] [a-q] [A-Q] svi znakovi osim novog reda (\n) a ili b grupa pasivna (ne-varijabilna) grupa rang (a ili b ili c) Sve osim a ili b ili c Slova (kurentna) od a do q velika (verzalna) slova od A do Q digitalne znamenke od 0 do 7 nth group/subpattern
^ poetak stringa,odn. poetak retka \A $ poetak stringa kraj stringa, odnosno kraj reda
\Z zavretak stringa \b graninik rijei \B nije rije \< Poetak rijei \> Kraj rijei
[0-7] \n
\ \Q \E
\c \s \S \d \D \w \W \x \O
Control character razmaknica \ space Not white space Digit [0-9] Not digit Word [a-zA-Z0-9_] Not word Hexadecimal digit Octal digit
"Escaping" is a way of treating characters which have a special meaning in regular expressions literally, rather than as special characters. Regular Expression Common Metacharacters
^ $ ( ) <
[ { \ | >
. * + ?
[:upper:] [:lower:] [:alpha:] [:alnum:] [:digit:] [:xdigit:] [:punct:] [:blank:] [:space:] [:cntrl:] [:graph:] [:print:] [:word:]
Upper case letters Lower case letters All letters Digits and letters Digits Hexadecimal digits Punctuation Space and tab Blank characters Control characters Printed characters Printed characters and spaces Digits, letters and underscore
Regular Expressions String Replacement $n $2 $1 $` $' $+ $& nth non-passive group "xyz" in /^(abc(xyz))$/ "xyz" in /^(?:abc)(xyz)$/ Before matched string After matched string Last matched string Entire matched string
\n \r \t \v \f \xxx xxx\xhh hh
New line Carriage return Tab Vertical tab Form feed Octal character Hex character
Regularno
Ostalo
(?<naziv>100)(?P=naziv) ${naziv}
referencija
Regular Expressions Assertions ?= ?! ? = ?!= or ? ! < ?> ?() ?()| ?# Lookahead assertion Negative lookahead Lookbehind assertion Negative lookbehind Once-only Subexpression Condition [if then] Condition [if then else] Comment
(?i)word(?-i) granica neosjetljivosti \w = [A-Za-z0-9_] neprazni znakovi (string) negacija - mora biti u kalasi velika i mala slova, ali i [ ] \ ' _ ^ tabulator (tab) novi odlomak (redak - ) u W, n (Unix), r (mac os) free spacing; ignorira razmake; ako elimo pisati regularni izraz u vie redaka
(?=neto) Gledanje unaprijed (pozitivno) (?!neto) Gledanje unaprijed (negativno) (?<=neto) Gledanje unazad (pozitivno) (?<!neto) Gledanje unazad (negativno)
(?=[x1y1])\d{x} definiranje onoga to slijedi Uinimo lakomi + lijeni: <.+?> ime kaemo im zadovolji uvjet, zaustavi traenje i kreni dalje (prije operatora)
Ostalo
(red)(green)(blue)\1\2\3 varijable (referenciranje) . (?:[123456789]) pasivna grupa vie nije varijabla . (?s) - proiruje znaenje toke koja inae oznaava sve znakove osim retka