U E D R , A S I H C RSS

Regular Expression/2011년스터디



1.

: 변
: 김경 김

2.


Regular Expression 고 더러 Regex 강력 느껴보.

3. 1


3.1. 뭔가?


Regular Expression다.

리가 배 대로 볼까

3.2. 나?

html 놓고 로러 or 개발 javascript 모드로 "문".matches("\Regex\"); 면 나.

java는 Matcher를 . (맞는 모르겠당)
Pattern.comppile("");
Matcher matcher = new Matcher(Pattern, " ");
matcher.find();

-

3.3. 문법?


. * + [] ^ $ | {} () \

[A-Za-Z0-9]
\w \W
\s \S

  ^  ^

. == 문(모든 것)
* == (명령)를 0개 때.
e.g. .*러 문(모든 것) 0개 다.
+ == (명령)를 1개 때.
[]대. == 면 됨. a-zA-Z 라던, 0-9라던.
$ 명령 는 것들 .
{} == 갯 가능. {0,2} 면 0~2개.
() == 명령들 |로 러가 .

4. 2



4.1. 1

<a herf ="dfdf"></a>
 

<a herf ="dfdf"> 기

answer : <.+?>

4.2. 2

 된 " " <a href = "class > </a>
<a href = "class" > </a>
<a href = "clas"s" > </a>


<html>
<a href ="abc"></a>
<a href ="abc"></a>
<a href ="dfw"></a>
<a href ="dfdof></a>
<a href ="dfdof class="dfdfd"></a>
<a href ="dfdof" class=dfdfd" name ="cdef"></a>
</html>

answer : <([^">]+|"[^">]*")+"[^">]*>

고, .

다면, 맞는것들'만' 내는 것 보는 떨까? 그러려면 다는...

4.3. 3

JavaScript
"http://www.naver.com www.naver.com naver.com google.co.kr http://kio.zc.bz/Lecture/regexp.html#chap05".match(/(http:\/\/)?([a-zA-Z]+\.)+[a-zA-Z]+\/?([^\s]+)*/g)
또 다른 () 대로 리고 닫, 대로 닫 .
  var str='<body onload="firprint(;" onkeydown="keyboard);"> <input value="pause" onclick="pause();"/>';


 str.match(/\s[^()\s]*([^()]*[)]|[(][^()]*)/g);
.. 대로 됐는데 --
  • 게 뭐 -ㅅ- -

str.match(/\s[^()\s]*([^()]*[)]|[(][^()]*)/g);
str.match(/\s([(][^(]*|[^)][)])*/g);
str.match(/((http:[^\s]*)|((\s[^/.]*[.][^/.]*)))\s/g);

 ((3*4)+2+4)-(23)) ((3*4)+(2+4)-23)) ((3*4)+(2+4)-(23)) (3*4)+(2+4)-(23)) ((3*4)+(2+4-(23))

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:27:54
Processing time 0.0140 sec