Skip to content

Commit

Permalink
chore: simplify regex
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed May 25, 2022
1 parent 189550b commit b7360ca
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}?(?=$| |\+|\.)(?:(?<=-[^ ]+)(?:\.(?:[\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 b7360ca

Please sign in to comment.