|
$abc =~ s/[\s]+//g;
| : gr(a|e)y => gray grey
? : house? => hous house
* : hello* => hell helloooooooooooooooo
+ : computer+ => computer computerrrrr
() : (terminal)* => "" terminalterminal
{n}: A.{3}e => Apple Abcde AAAAe
{n, }: nȸ ÀÌ»ó Ap{2,}le => Apple(o), Appple(o), Aple(x), Apble(x)
{n, m} nȸ ÀÌ»ó mȸ ÀÌÇÏ s.{3,4}ing => sleeping(o), shopping(o)
[ ] ¾È¿¡ °¡´ÉÇÑ ¹®ÀÚ¸¦ ¸í½Ã
^ ¹®ÀÚ µÚ¿¡ ³ª¿À´Â Á¶°ÇÀ» ¸¸Á·ÇÏÁö ¾Ê´Â ¹®ÀÚ
ex) ^[a-z] => a¿¡¼ z±îÁöÀÇ ¹®ÀÚ¸¦ Á¦¿ÜÇÑ ¹®ÀÚ¸¦ ã½À´Ï´Ù.
\w = [0-9a-zA-Z] : ¼ýÀÚ,¿µ¹®ÀÚ(´ë/¼Ò),_
\W = [^0-9a-zA-Z] : ¼ýÀÚ,¿µ¹®ÀÚ(´ë/¼Ò),_ ÀÌ¿ÜÀÇ ¹®ÀÚ
\s = [\t\n\r\f] : °ø¹é(½ºÆäÀ̽º, °³Çà, tab)
\S = [^\t\n\r\f] : °ø¹é(½ºÆäÀ̽º, °³Çà, tab) ÀÌ¿ÜÀÇ ¹®ÀÚ
\d = [0-9] : ¼ýÀÚ
\D = [^0-9] : ¼ýÀÚ ÀÌ¿ÜÀÇ ¹®ÀÚ
/g : Àü¿ª ¸ÅÄ¡ ¹®ÀÚ¿ÀÇ ¸¶Áö¸· ±îÁö °Ë»ö
/i : ´ë,¼Ò¹®ÀÚ¸¦ ±¸º°ÇÏÁö ¾Ê½À´Ï´Ù.
/x : °ø¹éÀ» ¹«½Ã, ÁÖ¼®À» Çã¿ë
/m : ^¿Í $°¡ \n ´ÙÀ½¿¡µµ ¸ÅÄ¡
/s : °³ÇàÀ» Æ÷ÇÔÇØ¼ ¸ÅÄ¡
$str=~/a.b/s;
print "$&";
$_="aaa abb aabb bb bbcc ";
foreach (/b\b/g){ $n++;}
length : ¹®ÀÚ¿ÀÇ ±æÀ̸¦ º¯¼ö·Î ¹Ýȯ
substr : ¹®ÀÚ¿ ÃßÃâ, ġȯ
index : ¹®ÀÚ¿ÀÇ Ã¹ À§Ä¡ ¹Ýȯ
split : ¹®ÀÚ¿À» ±¸ºÐÇÏ¿© ¸®½ºÆ® ¶Ç´Â ¹è¿¿¡ ÀúÀå
join : ¸®½ÃÆ®ÀÇ ¿ä¼Ò¸¦ ¿¬°á¹®ÀÚ·Î ¿¬°áÇÏ¿© ¹Ýȯ
tr/serach/replace/¿É¼Ç, y/serach/replace/¿É¼Ç
(?<=...)[±àÁ¤Çü ·èºñÇÏÀεå] : Ç¥Çö½ÄÀÌ ¿ÞÂÊ¿¡ ¸ÅÄ¡µÉ ¶§ ¼º°ø
(?<!...)[ºÎÁ¤Çü ·ÏºñÇÏÀεå] : Ç¥Çö½ÄÀÌ ¿ÞÂÊ¿¡ ¸ÅÄ¡µÇÁö ¾ÊÀ» ¶§ ¼º°ø
(?=...)[±àÁ¤Çü ·è¾îÇìµå] : Ç¥Çö½ÄÀÌ ¿À¸¥ÂÊ¿¡ ¸ÅÄ¡µÉ ¶§ ¼º°ø
(?!...)[ºÎÁ¤Çü ·è¾îÇìµå] : Ç¥Çö½ÄÀÌ ¿À¸¥ÂÊ¿¡ ¸ÅÄ¡µÇÁö ¾ÊÀ» ¶§ ¼º°ø
if($a=~/^(virtual[\s]+)*(function)/){ print "1:$1,2:$2 match\n";}
else {print "$a <- no\n";}
$& : ¸ÅĪµÇ´Â ¹®ÀÚ¿ Àüü
$` : ¸ÅĪµÇ´Â ¹®ÀÚ¿º¸´Ù ¾Õ¿¡ÀÖ´Â ¹®ÀÚ¿
$' : ¸ÅĪµÇ´Â ¹®ÀÚ¿º¸´Ù µÚ¿¡ÀÖ´Â ¹®ÀÚ¿
$1, $2, $3 : ±×·ìÀ¸·Î ¸ÅĪµÇ¾úÀ»¶§, ù¹øÂ°, µÎ¹øÂ° ±×·ì¿¡ ÀÖ´Â ¹®ÀÚ¿
$+ : ±×·ìÀ¸·Î ¸ÅĪµÇ¾úÀ»¶§, ¸¶Áö¸· ±×·ìÀÇ ¹®ÀÚ¿
$str=~/abc/;
print '$&='."$&\n";
print '$`='."$`\n";
print '$\'= '."$'\n";
print join " ",grep /E([ABDE]X|[BS]P|[DS]I)/,@A;
$a=~s/([^\d]+)([\d]+)/sprintf('%%%02x',ord($1)$2)/ge; |
|