The following code may get you started:
my $words = "y____x_z dddetr x_y erre yyy_";
while ($words =~ /([\S]*_[\S]*)/g) { print "$1\n"; };
It looks for any words containing an underscore-character and prints them. Due to the loop and the /g-modifier it will even all words containing an underscore
I intentionally wrote get you started, as there are some basic assumptions inside, e.g.:
- the "instance names" are seperated by whitespaces (and not commas ...)
- more than one underscore is OK, and the underscores may follwo each other
- an instance-name consisting only of underscores is fine
This webpage may help you understanding the regex.
HTH, Rata