Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a better way to find a valid semantic version string in the text? #50

Open
waruqi opened this issue Feb 6, 2020 · 0 comments

Comments

@waruqi
Copy link
Collaborator

waruqi commented Feb 6, 2020

Currently I use lua pattern matching to find valid semantic versions, but I don't feel very reliable.

 function semver.match(str, pos, pattern) 
     local patterns = pattern or {"%d+[.]%d+[-+.%w]*", "%d+[.]%d+[.]%d+", "%d+[.]%d+"} 
     for _, pattern in ipairs(table.wrap(patterns)) do 
         local version_str = str:match(pattern, pos) 
         if version_str then 
             local info = semver.parse(version_str) 
             if info then 
                 local instance = table.inherit(_instance) 
                 instance._INFO = info 
                 return instance 
             end 
         end 

Would it be better to provide a semver.match interface in the sv library for fast matching?

see xmake-io/xmake#677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant