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

getting number from string using regex

im wondering how I can get the number from the following string using regex

<@!1912983319>

I need the number inside of <@!>

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

i use const regex = /<@!(\d{17,19})>/g; i get to get <@3181> but unsure how to just get the number?

The number inside is just an example number, can be longer or shoter

>Solution :

Just remove(replace any non-number \d by empty string ''):

const num = "<@!1912983319>";
let number = num.replace(/[^\d]+/g,'');//1912983319
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