R
Randy Webb
I know that the /g flag will match all occurrences. Is there a way, with
a Regular Expression, to match all occurrences *except* the last one?
pattern = /df/g;
var myString = "asdfasdfasdfasdf";
var newString = myString.replace(pattern,'gh');
alert(newString)
Gives me: asghasghasghasgh as it should.
What I want: asghasghasghasdf Where the last one is not replaced.
a Regular Expression, to match all occurrences *except* the last one?
pattern = /df/g;
var myString = "asdfasdfasdfasdf";
var newString = myString.replace(pattern,'gh');
alert(newString)
Gives me: asghasghasghasgh as it should.
What I want: asghasghasghasdf Where the last one is not replaced.