DEV Community

Discussion on: The beauty of VerbalExpressions

Collapse
 
danielbastos11 profile image
Daniel Bastos • Edited

A few months ago, I needed a really complicated Regex for a project that I was working on. After struggling for a very long time with the syntax, I ended up writing a small library to generate the Regex for me. The thing is: I never used it again, so I never got to write a decent documentation.

Using my library, your example would look like that:

import { is, start, end, maybe, not } from 'frogjs';

new Regex(is(
  start, 
  'http', maybe('s'), '://',
  notBefore(' ', maybe('www.'))
  end
));

If you wanna check it out, take a look here: github.com/danielbastos11/frogjs
The test fold is quite complete (I'm surprised, actually).