I am trying to parse a multi line string and get the rest of the line following a pattern.
text:
hello john your username is: jj thanks for signing up
Your code is pretty much the Ruby way. If you don't want to use the global $1, you can use the 2 arg version String#[]:
$1
String#[]
match = text[/your username is: (.*)/, 1]