Search code examples
nginxlualua-patterns

Unexpected Regular expression result using dot symbol


I'm tring to detect file format: for instanse 23.ts

if I use string.match( entities[3], 'ts$' ) -- returns ts

if I use string.match( entities[3], '\.ts$' ) --returns error

if I use string.match( entities[3], '\\.ts$' ) --returns nil

if I use string.match( entities[3], '[\\.]{1}ts$' ) --returns nil

if I use string.match( entities[3], '.ts$' ) --works

for all strings like ats, bts, cts ... WHY? How can I detect . symbol?


Solution

  • You need to escape . with %..