0
我已經使用簡單的JavaScript正則表達式來刪除雙空間:正則表達式刪除雙空格的問題
例如,
" I am working on my Laptop. "
as
"I am working on my laptop."
因爲我使用了這個功能。但它的工作。
function valid(f)
{
f.value = f.value.replace(/[^a-zA-Z\s.'-,]/gixsm, '');
f.value = f.value.replace((/\s+/g, ' '); //remove more than 2 white spaces spaces.
f.value = f.value.replace(/^\s+|\s+$/g, ''); //remove spaces of before new line.
}
你的問題不清楚,請說明你的問題。 –
我需要刪除雙重聲明 >「我正在使用我的筆記本電腦。」 >「我正在使用我的筆記本電腦。」 因爲我寫這個正則表達式,它不工作。 – Aditii
是在這裏或在原始代碼中的雙打開paren錯字嗎? – jswolf19