I am having trouble getting a regex to work. This is the string.
我无法让正则表达式工作。这是字符串。
"some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here"
I need to remove the
我需要删除
:39.74908:-104.99482:272~
part of the string. I am using jQuery if that helps.
字符串的一部分。如果有帮助我正在使用jQuery。
4 个解决方案
#1
3
var your_string = "some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here";
alert(your_string.replace(/:.+~/, "")); /* some text would be here and Blah StTurn right over here */
#2
4
var str = "some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here";
alert(str.replace(/:[^~]+~/g, ""));
#3
0
You don't need an extremely complex regex for this:
你不需要一个非常复杂的正则表达式:
var str = 'Blah St:39.74908:-104.99482:272~Turn right over here';
str.replace(/:.*~/, '');
#4
0
var string = 'some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here'
var string2 = string.replace(/(?::-?\d+(?:\.\d+)?){3}~/g, '')
Will replace all instances of :number:number:number~
将替换所有实例:number:number:number~
The numbers can be negative and can have decimals
数字可以是负数,也可以有小数
#1
3
var your_string = "some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here";
alert(your_string.replace(/:.+~/, "")); /* some text would be here and Blah StTurn right over here */
#2
4
var str = "some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here";
alert(str.replace(/:[^~]+~/g, ""));
#3
0
You don't need an extremely complex regex for this:
你不需要一个非常复杂的正则表达式:
var str = 'Blah St:39.74908:-104.99482:272~Turn right over here';
str.replace(/:.*~/, '');
#4
0
var string = 'some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here'
var string2 = string.replace(/(?::-?\d+(?:\.\d+)?){3}~/g, '')
Will replace all instances of :number:number:number~
将替换所有实例:number:number:number~
The numbers can be negative and can have decimals
数字可以是负数,也可以有小数