import java.util.*;
import java.util.regex.*;

class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String s = "my friends passport numbers are V123456, V123457 and V123458";
		String rx = "(?:\\G(?!^)|\\bpassport\\b).*?\\b([a-zA-Z]{0,2}\\d{6,12}[a-zA-Z]{0,2})\\b";
		Pattern pattern = Pattern.compile(rx, Pattern.DOTALL);
		Matcher matcher = pattern.matcher(s);
		while (matcher.find()){
			System.out.println(matcher.group(1)); 
		} 
	}
}