def regex_find_txt(pattern, text, default="<STR_LIT>"):
text = str(text)<EOL>value = re.findall(pattern, text)<EOL>try:<EOL><INDENT>if not value:<EOL><INDENT>raise Exception<EOL><DEDENT>if not isinstance(value, type(default)):<EOL><INDENT>if isinstance(value, list) and len(value) == <NUM_LIT:1>:<EOL><INDENT>value = value[<NUM_LIT:0>]<EOL><DEDENT>value = type(default)(value)<EOL><DEDENT><DEDENT>except Exception:  <EOL><INDENT>value = default<EOL><DEDENT>return value<EOL>
RegEx search for pattern in text. Will try to match the data type of the "default" value
or return the default value if no match is found.
This is to parse IOS config like below:
regex_find_txt(r"remote-as (65000)", "neighbor 10.0.0.1 remote-as 65000", default=0)
RETURNS: 65001

:param pattern: RegEx pattern to match on
:param text: String of text ot search for "pattern" in
:param default="": Default value and type to return on error