Hi, I have a variable containing a string. The string can come in several ways:
// some examples of possible string
$var = 'Tom Greenleaf (as John Dunn Hill)'
// or
$var = '(screenplay) (as The Wibberleys) &'
// or
$var = '(novella "Four Past Midnight: Secret Window, Secret Garden")'
I need to clean up the string to get only the first element. like this:
$var = 'Tom Greenleaf'
$var = 'screenplay'
$var = 'novella'
I know this is a bit complicated to do but there is a pattern we can use.
Looking at the first variable, we can first check if the string contains the text ' (as'. If it does then we need to delete ' (as' and everything that comes after that.
In the second variable the rule we made in the first one also applies. We just need also to delete the parenthesis .
In the third variable if ' (as' was not found we need to get the first word only and then delete the parenthesis.
Well, thas all. I just need someone to help me do it because I'm new to PHP and I don't know regular expressions.... or another way to do it.
Thanks!!!!