Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .