Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have some URL like the following

http://www.SOMEURL.com/first-category/1343381-example-text-text-text-text-2000-a.html

What I want is to simple delete all of the text before and after the number 1343381 which is an ID.

I read that I could do this using Notepad++ Regular Expressions. Any ideas?

share|improve this question

1 Answer 1

If we can assume that SOMEURL and first-category don't contain digits, we can simply search for the first non-empty string of numbers and delete everything else.

Pattern:

Find what:    (.*?)(\d+).*
Replace with: \2

How it works:

  • .* is any arbitrary string of characters

  • ? makes .* lazy, i.e., it matches as few characters as possible

  • \d+ is a non-empty string of digits

  • () groups characters, where \2 refers to the second group

For more information about Regular Expressions, click here.

Example:

http://www.SOMEURL.com/first-category/1343381-example-text-text-text-2000-a.html
http://www.SOMEOTHERURL.com/some-category/1343382-example-more-text-2001-b.html

gets replaced with

1343381
1343382
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.