removeFirstWord method
Removes the first word and its surrounding punctuation, leaving the rest of the string.
Useful for stripping prefixes or processing command-line arguments.
Example:
'This is a sentence.'.removeFirstWord() // 'is a sentence.'
' Hello World'.removeFirstWord() // 'World'
'single'.removeFirstWord() // ''
Implementation
String removeFirstWord() {
return trim()
== '' ?
'' :
replaceFirst(RegExp('^[^$wordChars]*[$wordChars]+(?:-[$wordChars]+)*[^$wordChars]*'), '');
}