What does /.*=/ mean in the following jquery?
var id=this.href.replace(/.*=/,'');
this.id='delete_link_'+id;
What does /.*=/ mean in the following jquery?
var id=this.href.replace(/.*=/,'');
this.id='delete_link_'+id;
That's a regular expression that will select all characters before and including an equal sign.
The '.' means any character other than a newline.
The '*' means the character before it can appear any number of times.
The '=' is the regular equals sign.
So any character ('.') any number of times ('*') followed by an equals sign ('=').
That's a regular expression. The code will replace everything before the '='-sign (and the equal sign) with an empty string. So it will delete the = and everything before it.
My guess is that your url looks something like this http://mysite.com?id=3 then your variable id will contain 3.
The /.*=/ is a regular expression. It replaces any number of characters followed by an equals sign with an empty string.
It's a regular expression (or regex).
A regex is a search and replace method which uses pattern matching to locate parts of a string that fit a pattern. (Similar to how a wildcard dir *.*
lists all the files in the current directory).