Regex matching multiple lines multiple times

roaviograpype

New Member
I have a string like this:\[code\]Name: John DoeAge: 23Primary Language: EnglishDescription: This is a multilinedescription field that I want to captureCountry: Canada\[/code\]That's not the actual data, but you can see what I'm trying to do. I want to use regex to get an array of the "key" fields (Name, Age, Primary Language, Description, Country) and their values.I'm using PHP.My current attempt is this, but it doesn't work:\[code\]preg_match( '/^(.*?\:) (.*?)(\n.*?\:)/ism', $text, $matches );\[/code\]
 
Back
Top