For example, there is a string

<div> Дата прибытия: <input type="text" value="14.11.2016" /> </div> <div> Склад получения: <input type="text" value="Москва, ул. Тратата, 37" /> </div> 

Is it possible to put such text somehow in one pocket with the help of preg_math() Дата прибытия: 14.11.2016 ?

Not yet the whole PCRE studied.

  • one
    What is a pocket? If you are talking about variables, then no - in two separate and then merged. either preg_replace remove all unnecessary and leave only this line - Mike
  • @Mike pocket - mask - matches - search results php.net/manual/ru/function.preg-match.php - Jean-Claude
  • In one without too much text in the middle is impossible. Yes, and it is not required. You can always combine two capture groups after match - Mike
  • @JeanClaude, where did you find the term "pocket"? Formulate thoughts more clearly so that they understand you, programmers here, not politicians :) I realized, for example, that you have a problem combining two capture groups into one variable after working out preg_match ... - PinkTux
  • @PinkTux Koterov (many well-known book "PHP 7" Dmitry Koterov) uses the term pocket. In the internet, this term is also often found. - Jean-Claude

1 answer 1

Not. It's impossible.
The retaining grouping (pocket) contains a continuous sequence from the text to which the regular expression was applied.

Make several groupings (pockets) and combine them with PHP to achieve the desired result.