php - regular expression to extract foo, bar, baz and logical operator
992
String Parsing
foo_and_bar_and_baz_or_doe
expected result: foo, bar, baz and doe along with and, and and or.
i tried/(.*?)(_and_|_or_)/i
but its skipping last one.
actually sting is
having_tag_slugs_and_having_category1_slug_and_having_category2_slug_or_having_category3_slug
out put, i am looking is
having_tag_slugs
having_category1_slug
having_category2_slug
having_category3_slug
_and_
_and_
_or_
''
Answer
Solution:
You can try the following regular expression -
Hope that helps. Let me know how it goes :)
Answer
Solution:
Answer
Solution:
How about preg_split:
output: