So I have a string that possesses data I need to extract for my main program.
It looks something like this:
string = "[email:[email protected]][days:90]"
From this string I want to extract the data within the brackets and be able to split email and the email address by the colon so that I can store the word email and the email address separately to get something like this:
string = "[email:[email protected]]"
... some regex here ...
param_type = "email"
param_value = "[email protected]"
if param_type == 'email':
... my code to send an email to param_value ...
The string could ultimately have at most 2 pairs of brackets for different parameter types so that I can specify what functions to handle:
string = "[email:[email protected]] [days:90]"
...regex to split by bracket group ....
param_type1 = "email"
param1 = "[email protected]"
param_type2 = "days"
param2 = "90"
if param_type1 != "":
... email code ...
if param_type2 != "":
... run other code for the specified number of days ...
The main program already has default values for these 2 param_types, but I want there to be the option to specify the email address, days, both, or neither. If anything, I mainly need to know how to retrieve the email address as the online examples don't work for my situation.