Javascript正则表达式删除数字,然后一个空格? [英] Javascript regex to remove number, then a space?
本文介绍了Javascript正则表达式删除数字,然后一个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从字符串的开头删除数字和空格?
How would I go about removing numbers and a space from the start of a string?
例如,从'13 Adam Court,Cannock'删除'13' 。
For example, from '13 Adam Court, Cannock' remove '13 '.
推荐答案
搜索
/^[\s\d]+/
替换为空字符串。例如:
Replace with the empty string. Eg:
str = str.replace(/^[\s\d]+/, '');
这将从字符串的开头以任何顺序删除数字和空格。对于只删除数字后跟空格的内容,请参阅BoltClock的答案。
This will remove digits and spaces in any order from the beginning of the string. For something that removes only a number followed by spaces, see BoltClock's answer.
这篇关于Javascript正则表达式删除数字,然后一个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文