I'm trying to parse strings in PHP and store substrings into an array. The format of the string is as follows:
@SomeText1 ;SomeText2 $SomeText3 #SomeText4
(the "SomeText" substrings will never include the @;$# characters, so that's not a concern)
I want to extract SomeText1, SomeText2, ... separately using PHP, but there's a catch. Everything from the ";" is optional. So some example strings could be:
@ SomeText1 ; SomeText2
@ SomeText1 # SomeText4
@ SomeText1 $ SomeText3 # SomeText4
I'm at a complete loss on how to do this.
I've tried searching here for an answer to this but the closest I could find is (Matching an optional substring in a regex) and (Regex to capture an optional group in the middle of a block of input), but I failed when trying to apply that to my case.
Thank you very much in advance.