Reputation: 91
I have a string "[testid-1] is locked out / / Subject: / Account Domain: NM /"
and I need to extract "testid-1"
within the square braces and domain "NM"
out of the string using Lua script. I am trying to use the below code with no luck, I have also tried escaping [
.
aname=string.match(a,'[(.*)]')
Upvotes: 1
Views: 4324
Reputation: 91
Just figured that the escape character in lua is %. This code works fine:
aname=string.match(a,'%[(.*)%]')
adomain=string.match(a,'.*Account Domain: (%a+)')
Upvotes: 1
Reputation: 72312
You can do it in a single call:
aname, adomain = a:match('%[(.*)%].*Account Domain:%s*(.-)%s*/')
Upvotes: 2