4 ms·
for those who find regex not very readable: https://github.com/VerbalExpressions https://github.com/VerbalExpressions // Create an example of how to test for c
by qaq 9y ago
for those who find regex not very readable:
https://github.com/VerbalExpressions https://github.com/VerbalExpressions
// Create an example of how to test for correctly formed URLs
var tester = VerEx()
.startOfLine()
.then('http')
.maybe('s')
.then('://')
.maybe('www.')
.anythingBut(' ')
.endOfLine();
- pygy_ 9y agohttps://github.com/pygy/compose-regexp.js https://github.com/pygy/compose-regexp.js is another option (800 bytes mingzipped): const {sequence, suffix} = composeRegexp; const maybe = suffix("?"); const oneOrMore = suffix("+"); const urlMatcher = sequence( /^/, "http" maybe("s"), "://", maybe("www."), oneOrMore(/[^ ]/), /$/ );