Skip to content

Instantly share code, notes, and snippets.

@abdes-zakari
Created November 16, 2021 14:33
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 abdes-zakari/a94b7c1576ac9fe0ebb309111b273249 to your computer and use it in GitHub Desktop.
Save abdes-zakari/a94b7c1576ac9fe0ebb309111b273249 to your computer and use it in GitHub Desktop.
Javascript Regex Test
// Javascript Regex Test example
/*
[0-9]+ => Matches any digit (+) => one or more
\d{4} => Matches 4 digit
n^ =>Matches any string with n at the beginning of it
n$ => Matches any string with n at the end of it
\d{1,} Matches at least 1 or more of Digit
*/
var pattern = /^\/auftrag\/edit\/AB-(\d{4})-([0-9]+)$/;
var pattern2 = /^\/auftrag\/edit\/AB-(\d{4})-(\d{1,})$/;
//014657
var res = pattern2.test("/auftrag/edit/AB-2021-155464");
console.log(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment