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]]';
';
?>

1 Answer 1

1

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

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

DEMO

Sign up to request clarification or add additional context in comments.

2 Comments

thanks alot however I was really trying to match the industry in a longer block of text seen in: stackoverflow.com/questions/32066282/…
But this answers your current question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.