Skip to content

Instantly share code, notes, and snippets.

@erkobridee
Last active November 10, 2021 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erkobridee/a84579aa2a93c098860a095dfe385369 to your computer and use it in GitHub Desktop.
Save erkobridee/a84579aa2a93c098860a095dfe385369 to your computer and use it in GitHub Desktop.
example of how to write a multiline RegExp and keep under row max length lint rules
const DEVICES_REGEXP = new RegExp([
/Android|webOS/,
/|iPhone|iPad|iPod/,
/|BB10|BlackBerry/,
/|IEMobile|Opera Mini/,
/|Mobile|mobile/
].map(function(r) {return r.source}).join(''), 'i');
// output: /Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i
/*
const buildRegExp = (regexps: RegExp[]) =>
new RegExp(regexps.map((r) => r.source).join(''));
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment