Skip to content

Commit

Permalink
chore: optimize regex
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed May 25, 2022
1 parent b7360ca commit 4763bce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
@@ -1,5 +1,5 @@
export default function semverRegex() {
return /(?<=^v?|\sv?)(?:(?:0|[1-9]\d{0,9}?)\.){2}(?:0(?!\d)|[1-9]\d{0,9})(?:-(?:0(?!\d)|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)){0,100}?(?=$| |\+|\.)(?:(?<=-\S+)(?:\.(?:[\da-z-]*?[a-z-][\da-z-]*|0(?!\d)|[1-9]\d*)){1,100}?)?(?!\.)(?:\+(?:[\da-z-]+(?:\.[\da-z-]+)*){1,100}?(?![\w+-]))?(?!\+)/gi;
return /(?<=^v?|\sv?)(?:(?:0|[1-9]\d{0,9}?)\.){2}(?:0(?!\d)|[1-9]\d{0,9})(?:-(?:0(?!\d)|[1-9]\d*|\d*[a-z-]+\d*)){0,100}?(?=$| |\+|\.)(?:(?<=-\S+)(?:\.(?:[\da-z-]*?[a-z-][\da-z-]*|0(?!\d)|[1-9]\d*)){1,100}?)?(?!\.)(?:\+(?:[\da-z-]+(?:\.[\da-z-]+)*){1,100}?(?!\w))?(?!\+)/gi;
}

export const SEMVER_REGEX = semverRegex();

0 comments on commit 4763bce

Please sign in to comment.