code: def match_string(pattern, search_string):
      '''
      Match a pattern in a string
      '''
  
      rexobj = REX(pattern, None)
  
      rexpatstr = reformat_pattern(pattern)
      #print "rexpatstr: ", rexpatstr
  
      rexpat = re.compile(rexpatstr)
      rexobj.rex_patternstr = rexpatstr
      rexobj.rex_pattern = rexpat
  
      line_count = 1
      for line in search_string.splitlines():
          line = line.strip()
          mobj = rexpat.match(line)
          if mobj:
              populate_resobj(rexobj, mobj, line_count)
          line_count += 1
  
      return rexobf match_string(pattern, search_string):
      '''
      Match a pattern in a string
      '''
  
      rexobj = REX(pattern, None)
  
      rexpatstr = reformat_pattern(pattern)
      #print "rexpatstr: ", rexpatstr
  
      rexpat = re.compile(rexpatstr)
      rexobj.rex_patternstr = rexpatstr
      rexobj.rex_pattern = rexpat
  
      line_count = 1
      for line in search_string.splitlines():
          line = line.strip()
          mobj = rexpat.match(line)
          if mobj:
              populate_resobj(rexobj, mobj, line_count)
          line_count += 1
  
      return rexobj
docs: Match a pattern in a string