Get started with xregexp CDN
MIT licensed
XRegExp: library, adds lookahead, lookbehind, recursive RegExp features.
Tags:- regex
- regexp
Stable version
Copied!
How to start using xregexp CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with xregexp CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/xregexp/5.1.1/xregexp-all.min.js"></script>
</head>
<body>
<button onclick="searchText()">Search</button>
<p id="text">The quick brown fox jumps over the lazy dog.</p>
<p id="result"></p>
<script>
function searchText() {
const regex = XRegExp('\\bfox\\w*\\b', 'gi'); // Search for 'fox' followed by any number of word characters
const match = XRegExp.exec(document.getElementById('text').innerText, regex);
if (match) {
document.getElementById('result').innerText = `Match found at index ${match.index}`;
} else {
document.getElementById('result').innerText = 'No match found.';
}
}
</script>
</body>
</html>