R
R
Romi2022-01-14 15:37:42
Regular Expressions
Romi, 2022-01-14 15:37:42

How to understand this regular expression?

I met this here:

(?<=(?:.pdf))

What else does it do, besides extracting the string 'pdf' from the text?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Viktor Taran, 2022-01-16
@romicohen

(?<=) - to the right of this template, that is, the condition is present but it will not be included in the match. what will appear after this statement will get into the match.
.pdf - the bb template itself -
what was found
and that
(?:) - the usual group, but ?: says that it does not need to be allocated to a group, that is, it does not need to be turned into $ 1, then this question with a colon does not apply to the regular expression itself it's just a group, but because it doesn't need data, it doesn't matter. and in order to clog the conclusion, it must simply be forgotten.

D
d-sem, 2022-01-14
@d-sem

Positive Lookbehind
more specific https://learn.javascript.ru/regexp-lookahead-lookbehind
A small life hack on regular expressions. Sometimes it helps to use the tools to compose them. For example, https://regex101.com/r/GYjBIY/1
In the upper right corner there will be an explanation of how it works. And in the field below, you can use your own examples to see how the regular season works in different situations.

A
ab1, 2022-01-14
@ab1

Perhaps not all regular expressions are shown or cut off.
For example, it is also supplemented with the symbols "bb":
(?<=(?:.pdf))bb
see what was found on it
https://regex101.com/r/tAqWiW/1
+ Read the link to the Positive Lookbehind from the previous one (on Russian)
it also became clearer to me what it is)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question