3 ms·
> Brainf*ck Regular expressions look a lot like Brainfuck. A little trick is to break regexps up into various lines that do different things
by legrande 3y ago
> Brainf*ck
Regular expressions look a lot like Brainfuck. A little trick is to break regexps up
into
various
lines
that
do
different
things
- nivertech 3y agoyes, if your PL supports multiline regex with end of line comments[1]. BTW: that's what I'm doing when programming in kdb+/q (APL family language), even though it's less idiomatic. But I prefer readability and maintainability over succinctness. --- [1] var urlRegex = new RegExp( /(?:(?:(https?|ftp):)?\/\/)/.source // protocol + /(?:([^:\n\r]+):([^@\n\r]+)@)?/.source // user:pass + /(?:(?:www.)?([^/\n\r]+))/.source // domain + /(\/[^?\n\r]+)?/.source // request + /(\?[^#\n\r]*)?/.source // query + /(#?[^\n\r]*)?/.source // anchor );
- rak1507 3y ago> Regular expressions look a lot like Brainfuck. I'm sorry, have you ever seen a regular expression? No they do not.