[英]Remove only some commas from a string in JS
如果我给你这样的字符串:
如果您仔细查看文字,则会在以下位置出现逗号:
>, ., here, try
前两个很常见,需要删除,最后一个很正常,应该留在里面。大多数人会建议:
replace(/,/g, '')
但是,问题出在哪里,将删除所有逗号。 现在可以放心地认为,在结束括号或句点之后的任何逗号都可以删除。 任何其他逗号都应留在其中。
在此方面的任何帮助将不胜感激,我不知道正则表达式是否合适,或者是否有强调方式来做到这一点或做什么。
相反,用一个空字符串替换所有的逗号,全部更换>,用>和所有的.,有. 。
>,
>
.,
.
replace(/>,/g, '>')然后replace(/\\.,/g, '.')
replace(/>,/g, '>')
replace(/\\.,/g, '.')
[英]Remove commas from a string using js
[英]Remove commas from array in js
[英]Remove all commas from a string in Jquery
[英]Remove multiple commas from start and end of string
[英]Remove commas from the string using JavaScript
[英]Remove Quotes and Commas From Data String in React
[英]Getting substring from string separated with commas only
[英]Remove commas and make it a string?
[英]I want to remove some characters from a string in js
[英]JS parseInt string with commas
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.