package ru.yandex.autotests.direct.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by IntelliJ IDEA.
 * User: mariabye
 * Date: 22.08.11
 * Time: 13:47
 * To change this template use File | Settings | File Templates.
 */
public final class Parser {
    public static final String DATE_FORMAT_NOW = "yyyy-MM-dd";
    public static final String BID_PRICE_PATTERN="^(\\d){1,2}.(\\d){1,2}$";

    public static String getMatchFromString(String source, String pattern, int groupNumber){
        String result="";
        Pattern regex = Pattern.compile(pattern);
        Matcher m = regex.matcher(source);
        if (m.find())
            result = m.group(groupNumber);
        return result;
    }

  /*
      Валидация по паттерну
     */
    public static boolean matchPattern(String pattern_str, String str) {
        Pattern pattern = Pattern.compile(pattern_str);
        Matcher matcher = pattern.matcher(str);

        return matcher.matches();
    }
}
