0

The format of Url is - https://example.com/items/html5-templates/654321

  1. Firstly I want to take the link without last numbers. e.g: https://example.com/items/html5-templates/

And,

  1. Secondly, want to take only the last part (numbers) from the link. e.g: 654321

I need to get the regex code for using in a auto Parse plugin to my wp site,,,

And then I can customise the link as Like:

https://.....(link without last part)...../...anything..../...(only last numbers from the link format)...

Thanks a lot for your precious time,,,

  • 2
    What language/tool are you using? – Bohemian Sep 24 '22 at 14:52
  • I don't know. Because I'm using a third-party auto Parse plugin to parge product from another site to my wp site. But in this plugin supported these regex like [^0-9] to get numbers and ?a(|\s+[^>]+)> to avoid links from content. Which are written as find / replace rule into the plugin,,, But, at this time, I want to know about the above questions I specified. Thanks for sharing your surprising experiences,,, – Apurba Mondal Sep 24 '22 at 17:51

2 Answers2

1

use str.replace(/\/\d+$/, '') to remove /86886866 from string like https://www.wexperts.xyz/32423 The result will be like https://www.wexperts.xyz

Uzzwal Dhali
  • 71
  • 1
  • 8
0

Try something like this:

^(.*/)(\d+)$

The first part of URL will be in first capture group, and second capture group will be numbers.

erik258
  • 14,701
  • 2
  • 25
  • 31