S
S
SHentai2018-05-13 12:15:46
Regular Expressions
SHentai, 2018-05-13 12:15:46

A regular expression that checks for the presence of a tag in a string and the presence of a specific link in that tag?

Hello.
We need a regular expression that will check for the presence of the <a> tag and its link in the text.
For example:

<а href="https://kto-tut.ru/files/5767.mp3" class="sm2_button">5767.mp3</а> - можно проверять по самому тэгу, 
и смотреть уже внутри него href и если в href есть /files/ и .mp3, то вернуть true.

<а href="https://kto-tut.ru/files/sdfg235.mp3" class="sm2_button">5767.mp3</а> - true

<а href="https://kto-tut.ru/photo/14.jpg" class="sm2_button">13.jpg</а> - false

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-05-13
@SHentai

<a[^<>]*?href="[^"]*?\/files\/[^"]*?\.mp3"[^<>]*?>.*?<\/a>

https://regex101.com/r/2sGtKQ/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question