MapRegex
This transformer will take in a value and transform it based on multiple regular expressions defined in a JSON dictionary structure. The key:value pair of the JSON dictionary should be: "desired outcome": "regex to match" For example: { "Match 1": ".*match 1.*", "Match 2": ".*match 2.*", "Catch all": ".*" } The transformer will match in order of dictionary entries.
python · Community Common Scripts
Source
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 import re # Get the arguments args = demisto.args() # Get the input value value = args.get("value") results = value # Get and parse the JSON input try: json_regex = json.loads(args.get("json_regex")) except Exception as err: return_error(err) for k, v in json_regex.items(): if re.search(v, value): results = k break return_results(results)