M
M
Mikhail Vasiltsev2018-04-09 12:33:11
Regular Expressions
Mikhail Vasiltsev, 2018-04-09 12:33:11

How to write a regular expression for a string?

Hello. Can someone help a beginner, I'm weak in regular expressions, I don't know how to get the right part out of the string. The line template is:

ru.site.com/product/название-продукта-латиницей-которое-может-быть-от-20-до-100-символов/идентификатор(число)-от-10-до-12символов.html?куча-get-параметров

We need a regular expression that will pull out only an identifier (number) from such a string and hundreds of similar ones. I suspect that the easiest way here is to take from the 3rd slash, but there is still a difficulty that the length of id is not fixed and can be 10, and 11, and 12 characters.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanovskiy, 2018-04-09
@mihail430899

/\/product\/[Az]{20,100}\/([0-9]{10,12})\./

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question