Sami Sami -4 years ago 116
PHP Question

Preg Match To Get Everything Between Total || and \\n|}

So I want to capture everything between

Total ||
inside a string. Right now my current code looks like this:

preg_match('/(Total ||)(.*?)(\\n)/', $jsonwiki, $competitors);

But my regex fails and returns an empty array and I have no idea why?

Answer Source

i dont know regular expressions well, i just added some escaping

(Total \|\|)(.*?)(\\\\n)

| and \ escaped as they are used in the regular expression engine to mean particular things, so if you want a literal pipe you need \|

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download