Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex specific number inside quote

I am new to regex and have this cdn url that returns text and I want to use javascript to match and extract the version number. I can match the latestVersion but I am not sure how to get the value inside of it.

ex on text:

...oldVersion:"1.2.0",stagingVersion:"1.2.1",latestVersion:"1.3.0",authVersion:"2.2.2"...

I tried doing this line to display latestVersion:"1.3.0 but not successful

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const regex = /\blatestVersion:"*"\b/
stringIneed = text.match(regex)

And I only need 1.3.0 not including the string latestVersion:

>Solution :

Try adding a capture group () to match certain strings in the Regex.

/\blatestVersion:"([0-9.]+)"/
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading