cho45 (owner)

Revisions

gist: 140496 Download_button fork
public
Public Clone URL: git://gist.github.com/140496.git
Embed All Files: show embed
replace.scala #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.util.regex.Matcher
class MyString (s:String) {
def replace (source:String, replace:(Matcher => String)) = {
val m = source.r.pattern.matcher(s)
val sb = new StringBuffer(32)
while (m.find) {
m.appendReplacement(sb, replace(m))
}
m.appendTail(sb)
sb.toString
}
}
implicit def str2mystr (s:String) = new MyString(s)