admin管理员组文章数量:1323679
I already am doing a replace for the mas in an textbox. How would I replace if there is an "$" and a ma also in the same line?
function doValidate()
{
var valid = true;
document.likeItemSearchForm.sup.value = document.likeItemSearchForm.sup.value.replace(/\,/g,'');
return valid;
}
I already am doing a replace for the mas in an textbox. How would I replace if there is an "$" and a ma also in the same line?
function doValidate()
{
var valid = true;
document.likeItemSearchForm.sup.value = document.likeItemSearchForm.sup.value.replace(/\,/g,'');
return valid;
}
Share
edited Nov 26, 2020 at 19:17
peterh
1
asked Sep 26, 2011 at 13:35
Doc HolidayDoc Holiday
10.3k32 gold badges102 silver badges153 bronze badges
2
- 2 Why do you escape the ma? It has no special meaning in a regex. – ThiefMaster Commented Sep 26, 2011 at 13:37
- FYI, you should tag the answer as accepted if you find it adequate. – August Lilleaas Commented Oct 12, 2011 at 19:33
1 Answer
Reset to default 10Do you want to replace mas and dollar signs? Here's how:
"$foo, bar.".replace(/\$|,/g, "")
The regexp matches dollar signs or mas. The g
flag tells it to match the entire string instead of stopping after the first match.
本文标签: regexJavascript replace string charactersStack Overflow
版权声明:本文标题:regex - Javascript replace string characters - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742141574a2422603.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论