lib/WebDriverExpectedCondition.php
public static function elementTextMatches(WebDriverBy $by, $regexp)
    {
        return new static(
            function (WebDriver $driver) use ($by, $regexp) {
                try {
                    return (bool) preg_match($regexp, $driver->findElement($by)->getText());
                } catch (StaleElementReferenceException $e) {
                    return null;
                }
            }
        );
    }
public static function elementTextMatches(WebDriverBy $by, $regexp)
    {
        return new static(
            function (WebDriver $driver) use ($by, $regexp) {
                try {
                    return (bool) preg_match($regexp, $driver->findElement($by)->getText());
                } catch (StaleElementReferenceException $e) {
                    return null;
                }
            }
        );
    }
public static function elementTextMatches ( WebDriverBy $ by , $ regexp ) { return new static ( function ( WebDriver $ driver ) use ( $ by , $ regexp ) { try { return ( bool ) preg_match ( $ regexp , $ driver -> findElement ( $ by ) -> getText ( ) ) ; } catch ( StaleElementReferenceException $ e ) { return null ; } } ) ; }
An expectation for checking if the given regular expression matches the text in specified element.

@param WebDriverBy $by The locator used to find the element.
@param string $regexp The regular expression to test against.
@return static Condition returns whether the element has text value equal to given one.
An expectation for checking if the given regular expression matches the text in specified element .