Citation:
public Pattern conventionRates = Pattern.compile("^([^ ]{3}) (([^ ]{3}) | ([^ ]{6})) ([0-9]+)([^ ])([^ ]*)([ ]*)(.*)");
public String convention(String s)
{
Matcher matcherRates = conventionRates.matcher(s);
if (matcherRates.find())
{
String currency = matcherRates.group(1);
String type = matcherRates.group(2);
Integer i = Integer.valueOf(matcherRates.group(3));
String unit = matcherRates.group(4));
String pageNumber = matcherRates.group(5);
String extraTypeInfo = matcherRates.group(7);
return currency + "_" + type + "_" + i.toString() + unit;
}
else
{
throw new RunTimeException(s + " does not match index format!!");
}
}
Ca marche avec les chaines