一起文字开头的空格替换的正则方法

一行文字开头的空格替换的正则方法Code highlighting produced by Actipro CodeHighlighter (freeware)htt

一行文字开头的空格替换的正则方法
Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/



String str = "   酷  流行";

System.out.println(str.replaceAll("(?m)(?<=^ *) ", "&nbsp;"));

替换结果

&nbsp;&nbsp;&nbsp;酷  流行