We would like to know how to find a date (dd/mm/yyyy) in a string.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--from w w w . j a v a 2 s . c om-->
function containsDate(inputString){
return /\d{2}\/\d{2}\/\d{4}/.test(inputString)
}
//Expected results
document.writeln(containsDate("Today is 05/07/2015")); //= true
document.writeln(containsDate("Today is Friday")); //= false
}
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: