V
V
Vadim Timoshenko2015-11-25 16:07:12
PHP
Vadim Timoshenko, 2015-11-25 16:07:12

How to take something between characters using regular expressions?

There is a line like this: "||image|what-you-need-to-cut-and-assign-to-a-variable-to-output||".
You need to cut and assign to a variable what is between the character sets ||image| and ||, but it doesn't exit. Apparently due to the fact that special are used. characters "|" ?
I write like this:

if(preg_match('|/|/|image/|(.*)/|/|sei', $poster, $matches)) $poster = $matches[1];
else $poster = '';

How to cut correctly? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Muhammad, 2015-11-25
@PbI6A_KuT

The escape slash is \, modifiers come after /:
or even better:
\|\|image\|([^\|]*)\|\|/sei

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question