regularexpression

// Sample Regex
// Regex to find hl7 inthe reponse at lease 10 times : hl7{10,}
// Regex to find email : (“(\\w+@\\w+\\.[A-Za-z]{2,4})”)
// Regex to find various types of phone number: regexChecker(“( [0-9]( |-)?)?(\\(?[0-9]{3}\\)?)(( |-)?[0-9]{3})(( |-)?[0-9]{4})”, Response);

import java.util.regex.*;

def rawResponse = messageExchange.getResponseContent().toString()
def Response = rawResponse.replaceAll(“\\r\\n|\\r|\\n”, “”);
def valString = “45612368.*45612388” // These are two values from the Response

String myRegex = valString
Matcher digitMatcher = Pattern.compile(myRegex).matcher(Response)
boolean eval = digitMatcher.find();

if (eval == true )

{ log.info “Passed”}
else
{ log.info “Failed”}

assert eval == true

Advertisements