Error_Coding
Error_Coding

Reputation: 283

what would be regex for below pattern?

<msg info=access_denied>  

Access_denied can be anything "permit" "Thrashing"

I tried using regex

m/<msg info=([^]*)>/i

It is giving unmatched regex.

What should be actual and correct regex ?

Upvotes: 0

Views: 51

Answers (2)

Miller
Miller

Reputation: 35208

Your negated character class is missing the > character, for anything not >:

m/<msg info=([^>]*)>/i

However, just note that if your data is XML, you should consider using an actual XML Parser to pull that data.

Upvotes: 4

theglauber
theglauber

Reputation: 29645

I think you are looking for

/<msg info=([^>]+)/

Assuming the input is as you described (no quotes, etc).

Upvotes: 5

Related Questions