Reputation: 39427
I'm working in lua, and i need to match 2 parts of a line that's taken in through file IO. I'm inexperienced with regexes and i'm told lua doesn't have full regex support built in (but i have a library that provides that if need be). Can someone help me with building regexes to match the parts necessary?
"bor_adaptor_00.odf" 3.778
^^^^^^^^^^^^^^ ^^^^^
i need this in and this in
a string a number
Upvotes: 0
Views: 7528
Reputation: 43110
I made an example:
s = '"bor_adaptor_00.odf" 3.778'
val1, val2 = string.match(s,'(%b"")%s*([.0-9]*)')
print(val1, val2)
output:
"bor_adaptor_00.odf" 3.778
Upvotes: 3
Reputation: 1567
^"(.*?)"\s+(\d[\d.]*)$
Explanation:
No idea how to use that in lua, but should help to get you started.
On the other hand, this is a really simple string, so it could be a good idea to parse it without regular expressions.
Upvotes: 3