
com.griddynamics.qa.tools.StringParser Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2015, Grid Dynamics International and/or its affiliates. All rights reserved.
* Grid Dynamics International PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.griddynamics.qa.tools;
import org.junit.Assert;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Class containing utils for working with String objects
*
* @author ybaturina
*/
public class StringParser {
/**
* Method returns string which is matched for the provided regexp
* @param source - original string
* @param regexp - regular expression which should be matched
* @return
*/
public static String getMatchString(String source, String regexp) {
Pattern pattern = Pattern.compile(regexp);
Matcher matcher = pattern.matcher(source);
Assert.assertTrue("No matches were found for regexp <" + regexp + "> for string = " + source, matcher.find());
return matcher.group();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy