lookahead of regexp of javascript
<script type="text/javascript" charset="utf-8">
function doc (argument) {
document.write(argument);
document.write("<br />\n");
}
var pp = /^\d(?=\.\d+)/; // pattern positive lookahead
doc('3.14'.match(pp));
doc('3.'.match(pp));
doc('.14'.match(pp));
var pn = /^\d(?!\.\d+)/; // pattern negative lookahead
doc('3'.match(pn));
doc('3.14'.match(pn));
doc('.14'.match(pn));
</script>
No comments :
Post a Comment