各位好,有i一个问题请教。现在有一个字符串,形式为:
vertex:http://www.myspace.com/aaron
想将其替换为:aaron请问正则表达式该如何写呢?或者使用String.replaceAll(。。) 方法也行。谢谢~~~

解决方案 »

  1.   

    只论结果,不论过程!
    String str = "vertex:http://www.myspace.com/aaron";int index = str.lastIndexOf("//");System.out.println(str.subString(index));
      

  2.   

    只论结果,不论过程!
    String str = "vertex:http://www.myspace.com/aaron";int index = str.lastIndexOf("//");System.out.println(str.subString(index));
      

  3.   

    如果仅仅是楼主所举的例子,是没必要用正则的String test = "vertex:http://www.myspace.com/aaron";
    String result = test.substring(test.lastIndexOf('/')+1);
    System.out.println(result);