I am trying to create a regex for this text *[Failure] : Automation Failure, Reason - Unable to find Watch Live button on title detail page*, I want to extract anything between *[Failure] : and *. I tried coming up with \*\[Failure][ :,-,-] [a-zA-Z0-9] \* but this does not work.
In my case desired output is Automation Failure, Reason - Unable to find Watch Live button on title detail page
CodePudding user response:
If you simply want to get everything between the '*[Failure] :' and the '*', you can use a lookbehind and a lookahead to make the regex:
(?<=\*\[Failure] : ).*(?=\*)
(?<=\*\[Failure] : )looks behind for'*[Failure] :'(?=\*)looks ahead for a'*'
CodePudding user response:
You are missing some essential characters in the 2 character classes that you use to span the match till *, and to only get the part in between you can use a capture group or else you will have the full match only.
\*\[Failure][ :,-] ([a-zA-Z0-9, -] )\*
