http://olx.ua/obyavlenie/ischu-otdelnuyu-komnatu-dlya-dolgosrochnoy-arendy-IDmQ5Is.html 

Need to get mQ5Is . Well, advise what to read, so as not to ask such banal questions.

  • First you need to understand what you can rely on. That you did not specify. I suspect that it is necessary to look for before .html But why exactly these letters in the answer ... Are they strictly defined quantity or maybe after -ID? Well, to read ... in my Wikipedia it’s enough ru.wikipedia.org/wiki/… - Mike
  • If you need between '-ID' and '.html', then like this: regex101.com/r/rA0qH5/2 . - Sasha Chernykh
  • @ SashaBlack And why are the views forward and backwards in this case? Better than just - regex101.com/r/rA0qH5/3 - Bookin
  • @ SashaBlack black that's right, add back - andee
  • one
    @Bookin Not everyone is ready to work in the program with a dedicated mask, i.e. c that receive parentheses. Sometimes it is convenient to take the whole match entirely - in this case, not an exciting check and need. Why specifically here and how convenient the vehicle is - a rhetorical question - Mike

1 answer 1

Once the top-starter has arranged the suggested comment, I am writing it as an answer.

Template : (?<=-ID).+(?=\.html)
Demonstration : https://regex101.com/r/qX8eT4/1

View forward and backward

This regular expression searches for text between -ID and .html . True, if the link somewhere already has a combination of symbols -ID , then on this link the pattern will no longer work - https://regex101.com/r/qX8eT4/2 . I hope that the author of the question will not have such links.

.+ - any character other than line breaks repeated 1 or more times.

-ID and \.html are literals -ID and .html respectively. The point before html must be escaped, so that it acts as a literal and does not consume text, where instead of a point there is any character other than line IDSashaBrilliantFhtml , like IDSashaBrilliantFhtml or IDSashaBrilliant7html - https://regex101.com/r/qX8eT4/3 .

?<= and ?= - operators look back and look forward, respectively. We found the expression -IDSashaBrilliant.html , but we do not need -ID and .html ; in order not to consume them, these context search operators are applied.

You can read about context searching in Ben Fort's book Regular Expressions. 10 minutes to class ” , lesson 9, page 111.