/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String text = "The price is 1 000$ and 2 000 . 00 EUR another pice 34 000 , 00 EUR. You have to pay 1400 EUR, and you have to pay extra 2000$";
		String regex = "(\\bpay(?:\\s+extra)?\\s*)?([0-9][\\d\\s,.]*)(?:\\$|EUR)";
        Pattern pattern = Pattern.compile(regex);
        Matcher m = pattern.matcher(text);
        List<String> res = new ArrayList<>();
		while (m.find()) {
            if (m.group(1) == null) {
            	res.add(m.group(2).replaceAll("[,.]\\s*\\d+|\\D", ""));
            }
		}
		System.out.println(res);
	}
}