如何从链接中提取单词?

发布于 2025-02-13 21:40:12 字数 357 浏览 0 评论 0原文

面临问题。我获得了一个链接,需要提取密码-RESET,我该怎么做?例如,要获取代码我使用QUERYPARAMETERS ['code'],但是如何从链接中提取password-password-reset我需要此文本进行导航?

链接

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

需要获得

password-reset

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

password-reset

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独陪着我 2025-02-20 21:40:12

使用substring,代码将在最后一个/和第一个之间提取文本:

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);

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);
病女 2025-02-20 21:40:12

如果您有相同的链接,并且知道字母的索引位置,这将对您有所帮助。

String myLink = 'https://test.test.test.test/app/password-reset?code=6294';
String wantedString = myLink.substring(32,46);

If you have the same link, and know the index position of the letters.This would be helpful for you.

String myLink = 'https://test.test.test.test/app/password-reset?code=6294';
String wantedString = myLink.substring(32,46);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文