嘿,我试图取代在JavaScript换行符替换不工作:(
<blockquote>...</blockquote>
与
>> ...
这是我的代码:
var testhtml = 'sdkjhfbs <blockquote>skldfjsfkjghbs\n sdjkfhb ksdbhv isl\n kdjbhdfgkj bs</blockquote>kdjfgnkdfj';
alert(blockquoteConvert(testhtml));
function blockquoteConvert(html) {
return '>>' + html.
replace(/<blockquote>([^]+)<\/blockquote>/gi,"$1").
replace('/\n/','\n>> ');
}
但它没有找到Linebreaks(我用indexOf('\ n')查过)
我该怎么做?
和RegExp对象也会。 ''abc \ ndef'.replace(new RegExp('\\ n','g'),'\ n >>')' – ZJR 2010-01-10 15:13:57