in reply to split string at variable position with matching

reusing choroba's rindex idea, here a debugger demo using substr instead of a complicated regex (the p are just for printing the preliminary results)
DB<34> $string = "hello my * name is Rob * and * I am a very nice pe +rson * at least * I think * so" DB<35> p $pos = rindex $string, ' * ', 30 28 DB<36> p $left = substr $string, 0, $pos+3, "" hello my * name is Rob * and * DB<37> p $string I am a very nice person * at least * I think * so DB<38> p "<$left>" <hello my * name is Rob * and * > DB<39>

please note the trailing whitespace in $left

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery