Problem with Regular Expressions
I'm trying to determine if the id of an element matches a String that has multiple parts.
The value of this.id is "platform_SWFUpload_0_0" but the result of thisID.match (pattern) is null.
function platformChange (this)
thisID = this.id;
var pattern = "SWFUpload_\d_\d";
var match = thisID.match (pattern);
Can someone please explain what I'm doing wrong and how I can make this work?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
thisID = el.id;
//I'm assuming that you may have wanted to pull the numbers out of the id also:
var pattern = /^SWFUpload_(\d+)_(\d+)$/;
var match = thisID.match(pattern);
var arr = (match !== null) ? match : ['match', 'was', 'null'];
<button type="button" id="SWFUpload_10_0" onclick="platformChange(this);">Click Me</button>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)