0

I'm struggling to find the correct regular expression to return:

'industry =[[Banking]], [[Financial services]] |products = [[Investment Banking]]'

from the following:

<?php
$x =  '[[Basel]] |key_people = [[Axel A. Weber]] (Chairman){{br}}[[Sergio  
Ermotti]] (CEO) {{br}} |area_served = Worldwide |industry =[[Banking]],   
[[Financial services]] |products = [[Investment Banking]]';
';
?>
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274

1 Answers1

1

Use preg_match to garb the last two parts of | delimited text.

preg_match('~(?<=\|)[^|]*\|[^|]*$~', $str);

DEMO

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
  • thanks alot however I was really trying to match the industry in a longer block of text seen in: http://stackoverflow.com/questions/32066282/preg-match-all-not-returning-expected-values?noredirect=1#comment52030149_32066282 – Damien Rice Aug 18 '15 at 20:07
  • But this answers your current question. – Avinash Raj Aug 19 '15 at 04:29