<pre class="java" name="code">/**
* 这里只总结一些与java不同的的用法,但是又比较常用的API
*/
/**
* " ' ' "的用法
*/
String c = "'Hello Triple" + "Multiple lines'";//print 'Hello TripleMultiple lines' /**
*索引用法
*/
String sample = "Hello world";
println(sample[4]); // Print the 5 character in the string :o
//Print the 1st character in the string starting from the back
println(sample[-1]);// print d
println(sample[1..2]);//Prints a string starting from Index 1 to 2: el
println(sample[4..2]);//Prints a string starting from Index 4 back to 2 : oll /**
* 字符串连接
*/
String a = "Hello";
String b = "World";
println(a + b); //print HelloWorld
println( a.concat(b))//print HelloWorld
/**
* 在一个字符串内匹配正则表达式
*/
String s = "He5lloW2or3ld";
s.eachMatch("\\d") {
ch -> println ch //