PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 6, 2022

[FIXED] How can I get the specific part from the link using regular expressions (regex),,,

 November 06, 2022     nsregularexpression, regex, regex-group, regex-lookarounds, url-rewriting     No comments   

Issue

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,,,


Solution

Try something like this:

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

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



Answered By - erik258
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing