This is my first question here and I am messed up with strings. I have some strings in the following format:
I will be here (I may or may not be here) (30-Apr-2013)
I am still here (15-Feb-2013)
I am still here(I may not be here) (I may not be here) (9-Apr-2013)
I need to separate the date from the name. As you can see, the number of brackets may vary, but I need the last one only ( rest of the string will be treated as name).
Expected output:
1. array( 0=> 'I will be here (I may or may not be here)' , 1=> '30-Apr-2013' )
2. array( 0=> 'I am still here' , 1=> '15-Feb-2013' )
3. array( 0=> ' I am still here(I may not be here) (I may not be here)' , 1=> '9-Apr-2013' )
What is the best way to achieve this?
You can use
strrposto find the last occurrence of(and then you can usesubstrandtrimto get the sub-strings and trim them to the result you want.E.g.