for ($string) { s/-L+|L+-/-/g; s/^L+//; s/L+$//; print join ', ', /([CSHL]{2,})/g; }