String.search returns the (character) position of the (first) matched regular expression. <!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>String.search()</title>
<script type="text/javascript">
function main() {
reNum = /\d/; // Search for a number
str = 'foo 42 bar';
posFirstNum = str.search(reNum);
var out = document.getElementById('out');
out.innerHTML = "The position of the first number in <b>" + str + "</b> is: " + posFirstNum;
}
</script>
</head>
<body onload='main()';>
<div id="out"></div>
</body>
</html>