Regex expression to extract Status?

  python, python-3.x, regex

I am new in the regex field and looking for regex expression to match the following cases (By order):

If you have any suggestions kindly mention them (My goal is to extract status of a response message from server, it can be in json format, text etc…)

  1. New line or & sign.

  2. the word status or 'status' or "status" – not case sensitive.

  3. = sign or : sign wrapped by spaces or taps (equal number from both sides)

  4. Stop at the next & or end of line.

Important Note: all of the match should be case insensitive, so status is the same as StAtUs to me.

To make things more clear and easier I have added some quality-examples:

Examples of match (should return yes):

&status:yes
&status=yes
status:yes
status=yes&
&status : yes&
&status = yes
stAtus : yes
stAtus = yes
&status  :  yes
&status  =  yes
status  :  yes
status  =  yes

Examples of match (should return "yes"):

&"status":"yes"
"status":"yes"

Examples of no-match:

status      =  yes
&sstatus = yes
&"status':"yes"

Source: Python Questions

LEAVE A COMMENT