Working on a bot application, so I need to extract the values from the message string and pass it to a variable. The message string can be in different ways like :
message = 'name="Raj",lastname="Paul",gender="male", age=23'
message = 'name="Raj",lastname="Paul",age=23'
message = 'name="Raj",lastname="Paul",gender="male"'
The data user provided can contain all values, or sometimes age or gender field will be missing.
Where I am stuck is , I am not sure how to check if age is present in the message text. If it is then extract value corresponding to age. If age is not in message, ignore age.
It is possible to check each one word in a loop and extract the string, but it becomes quite lengthy. Please let me know if there is more easier ways
Like
if Age is present in message then get the value of age,
if lastname is present in message then get the value of lastname
if gender is present in message then get the value of gender
if name is present in message then get the value of name
ageis in message you can doif 'age' in message:if message.startswith('age=') or ',age=' in message:. This way you won't get false positives on things likelastname="Sager"