code: public static Condition matchText(final String regex) {
      return new Condition("match text") {
        @Override
        public boolean apply(Driver driver, WebElement element) {
          return Html.text.matches(element.getText(), regex);
        }
  
        @Override
        public String toString() {
          return name + " '" + regex + '\'';
        }
      };
    }
docs: Assert that given element's text matches given regular expression
  
  <p>Sample: <code>$("h1").should(matchText("Hello\s*John"))</code></p>
  
  @param regex e.g. Kicked.*Chuck Norris - in this case ".*" can contain any characters including spaces, tabs, CR etc.