I've searched a million similar questions and don't find the answer to this specific scenario.
Problem:
<?php
$text = "some words | other words";
$text2 = "some words > other words";
$text3 = "some words < other words";
print preg_match("/\s+\|\t/", $text); //this works, will print 'true'
print preg_match("/\s+(<|>|\|)\t/", $text2); //never true for $text2 or $text3
print preg_match("/\s+[<\|>]\t/", $text3); //never true for $text2 or $text3
?>
I need something that will be true for all 3 scenarios.
I've tried look-behind and look ahead and I cant figure out anything there that works. Those are still somewhat foreign to me.
I'm not sure if I understood correctly your question. But if you want to match |
, <
and >
then you could use a simple regex like this:
[|<>]
And if you want to match the spaces and words then you could use something like this:
\w+\s+[|<>]\s+\w+
You guys are correct. My code does already work. The problem I am having is that when there is a '<' instead of a '|' the code is no longer using a tab after it, its only doing spaces there instead....which was unexpected and difficult to tell the difference by just looking at it.
Thanks for all the help. It seemed a lot more complicated than it was. Just hard to tell difference between spaces and tabs when troubleshooting. And yes those spaces/tabs have to be there.