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 9ac980b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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*|[\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;
}

export const SEMVER_REGEX = semverRegex();

0 comments on commit 9ac980b

Please sign in to comment.