K
K
Konstantin Maslennikov2021-10-28 15:42:03
Regular Expressions
Konstantin Maslennikov, 2021-10-28 15:42:03

How to get the given expression from a string?

Good afternoon! Need help. I can't figure out the regex..

There is a line:

poster|text||title|text||title_en|text||year|2020||description|any characters can be here||countries|text||genres|text|| .....

Need to get ||description|some text||

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Slava Rozhnev, 2021-10-28
@kosta6832

/(\|\|description\|[^|]+\|\|)/
php code :

<?php
$string = 'poster|text||title|text||title_en|text||year|2020||description|тут могут быть любые символы||countries|text||genres|text|| .....';
preg_match('/(\|\|description\|[^|]+\|\|)/', $string, $matches);

var_dump($matches[1]);

A
Aetae, 2021-10-28
@Aetae

/(?<=\|\|description\|)[\s\S]*?(?=\|\||$)/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question