Reputation: 1524
For example
var string = 'width="300" height="650"'
i would like to update height in that string and get something like
string = string.replace(/height="..."/g, 'height="150"');
//... as any symbol
how to make reg expression who does not care value of height, to replace it with new one?
You can play with it here, in example: JsFiddle
Upvotes: 0
Views: 180
Reputation: 2655
for case insensitive use:
.replace(new RegExp(/height=\"[0-9]+\"/gi), 'height="150"');
Upvotes: 2
Reputation: 26320
var string = 'width="300" height="650"';
string = string.replace(new RegExp(/height=\"[0-9]+\"/g), 'height="150"');
Upvotes: 4