Hi!!
I thought this was going to be an easy regex problem but I am having some problems.
I have a string:
$string = "Code: 6562 Name: John Smith Product: Cheeseboard and knife Colour: Orange Material: Stelle and plastc";
I am trying to use a regex to extract the 'data' from this string, I need to get the type of data (ie. Colour) followed by it value (ie. Orange). But I don't always know what the type of data is. I do know that it will be allways be Xxxxx: (ie. CapitalLetter-letters- colon)
Here is my code
if(preg_match_all("/[A-Z][a-z]🙁.)[A-Z][a-z]*:/", $string, $reg)) :
for($j=0; $j<count($reg[0]); $j++) :
echo "<b>" . $reg[0][$j] . "</b><br>";
endFor;
else :
echo "no match"
EndIf;
I have tried many variations of this but still seem to get nowhere.
Anyone willing to give me a pointer in the right direction?
Thanks