php - regular expression to extract foo, bar, baz and logical operator -
string parsing
foo_and_bar_and_baz_or_doe
expected result: foo, bar, baz , doe along and, , and or.
i tried /(.*?)(_and_|_or_)/i
skipping last one.
actually sting
having_tag_slugs_and_having_category1_slug_and_having_category2_slug_or_having_category3_slug
out put, looking is
having_tag_slugs having_category1_slug having_category2_slug having_category3_slug _and_ _and_ _or_ ''
you can try following regular expression -
/(.*?)(_and_|_or_|$)/im
hope helps. let me know how goes :)
Comments
Post a Comment