// 2015-02-13 13:40:47 (금요일)
locationData = "Liverpool, England: 53d 25m 0s N 3d 0m 0s"
myRegularExpression = /([a-zA-Z]+), ([a-zA-Z]+): ([0-9]+). \
([0-9]+). ([0-9]+). ([A-Z]) ([0-9]+). ([0-9]+). ([0-9]+)./
matcher = ( locationData =~ myRegularExpression )
println locationData
println locationData.getClass()
println matcher.matches()
println matcher.getCount()
println matcher[0]
println matcher[0][0]
println matcher[0][1]
println matcher[0][6]
// 결과가 이차원배열에 들어간다는 사실.
// Non-matching group
names = [
"Graham James Edward Miller",
"Andrew Gregory Macintyre",
"No MiddleName"
]
printClosure = {
matcher = (it =~ /(.*?)(?: .*)* (.*)/)
if ( matcher.matches())
println( matcher[0][2]+", " + matcher[0][1])
}
names.each(printClosure)
// 문자열 바꾸기
excerpt = "At school, Harry had no one. Everybody knew that \
Dudley's gang hated that odd Harry Potter "+
"in his baggy old clothes and broken glasses, \
and nobody liked to disagree with Dudley's gang.";
println excerpt
matcher = (excerpt =~ /Harry Potter/)
excerpt = matcher.replaceAll("Tanya Grotter")
matcher = (excerpt =~ /Harry/)
excerpt = matcher.replaceAll("Tanya")
println("Publish it! " + excerpt)
//
// Greedy operator
// Reluctant operator
//
|
---|
2015년 2월 12일 목요일
groovy 연습 4
Firefly Algorithms
firefly algorithm 001 Firefly Algorithms ¶ 반딧불 알고리즘 번역 요약 ¶ References [1] X. S. Y...
-
// 그루비를 배워보자. /* 주석이 되나. */ // 그래. 이것이 그루비 코드다. // 2015-02-12 11:34:45 (목요일) println( "Hello world" ) printl...
-
firefly algorithm 001 Firefly Algorithms ¶ 반딧불 알고리즘 번역 요약 ¶ References [1] X. S. Y...
-
;; 참조: ;; http://pupeno.com/2011/08/16/why-i-love-lisp/ ; 2015-02-13 23:44:49 (금요일) ; 2015-02-14 14:31:10 (토요일) ; 클로저를 배워보자...