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

How to extract a word from a link?

Faced a problem. I get a link and I need to extract a password-reset, how can I do this? For example, to get code I use queryParameters['code'], but how do I extract the word password-reset from the link, I need this text for navigation?

link

https://test.test.test.test/app/password-reset?code=6294

need to get

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

password-reset

>Solution :

Use substring, the code will extract the text between the last / and the first ?:

var link = "https://test.test.test.test/app/password-reset?code=6294";

var start = link.lastIndexOf('/') + 1;
var end = link.indexOf('?');

var extract = link.substring(start,end);

print(extract);
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