Questions tagged [lua-patterns]

Lua's native string pattern matching facility. Note that Lua patterns are not equivalent to a regex.

Lua's built-in string patterns employ syntax similar to POSIX- or Perl-style regexes, but there are many basic differences. This tag should be used instead of the regex tag, to forestall irrelevant answers from responders who are familiar with regexes but not with Lua.

Using this tag instead of the regex also tag makes it clear that you're not using regexes provided via an imported library.

356 questions
0
votes
1 answer

when using pattern matching in Lua with parenthesis, how does one use "%2" to get the capture group

I am trying to parse a text file and converting it to a table (or JSON) using lua. Example test file is as follows: ipv4 2 tcp 6 3598 ESTABLISHED src=192.168.1.117 dst=137.194.2.78 sport=59078 dport=80 packets=4 bytes=298 src=137.194.2.78…
0
votes
2 answers

Corona string.find() : Finding "."

I'm trying to split a string into two parts, which is divided by a '.' character. But string.find() function cant handle that I have this kind of string local test = "345345.57573" I tried local start = string.find( test, "." ) local start =…
Doğancan Arabacı
  • 3,934
  • 2
  • 17
  • 25
0
votes
1 answer

Lua or XSL - Pull words out of string Lync

I have a document that I'm processing with a Lua and/or XSL, since the solution that I'm using allows both. The data being processed is a compilation of an IM conversation from Lync 2013. I've been able to write some pattern matching scripts that…
Steve A
  • 33
  • 1
  • 4
0
votes
1 answer

Lua - extract a string using patterns

I'm just starting on Lua Patterns. I have a string |2|34|56|1 How do I extract the numbers from the string? I can parse the string manually and exclude all the '|' characters. But I'm sure using Lua patterns will be much simpler. How do patterns…
SatheeshJM
  • 3,575
  • 8
  • 37
  • 60
-1
votes
1 answer

How to create a word set/class in Lua pattern matching?

I am trying to create a word-set (class) instead of the char-set (class) in Lua. For Example: local text = "hello world, hi world, hola world" print(string.find(text, "[^hello] world")) In this example, the program will try to match any part of the…
Jazz
  • 214
  • 2
  • 10
-1
votes
1 answer

How would I do pattern matching on this string in lua?

I have a string which contains a path to a file: C:\Users\user\directory\build.bat Is there a way I can remove the word between the last backslash and the second last backslash (in this case it is directory), however I would like a way to do this…
Ali Awan
  • 180
  • 10
-1
votes
1 answer

How to check url whether url is valid in lua?

I want to check if url is valid, what is the correct regexp to do that in lua? I tried regexp like this string.match('https://stackoverflow.com/', '[a-z]*:\/\/[^ >,;]*') but getting error invalid escape sequence near…
Sergey Lapin
  • 1,008
  • 3
  • 12
  • 21
-1
votes
1 answer

Get numerical values txt file using delimiters

I have a txt file with the following text: 5;2;8;3; I need get the numeric values, using ; as delimiter, and put them into an array. How could this be achieved?
chele
  • 51
  • 2
-1
votes
1 answer

LUA Pattern to retrieve a specific part of text from a string

So I have a string in Lua that is exactly like the following: [[ en[What is your job] pt[Qual é o seu trabalho?] ]] As you might expect, I want to sometimes retrieve anything inside "en[]" and in other times "pt[]" and put the text inside a new…
Alexandre Severino
  • 1,563
  • 1
  • 16
  • 38
-2
votes
3 answers

what does "(.+)"}], in lua pattern matching mean

i got this code that take webhook message but i dont understand the pattern matching behind it function getContent(link) cmd = io.popen('powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;…
Retaker
  • 33
  • 6
-2
votes
1 answer

Lua detect a character/string repeated in all text

I have several documents on a folder. Some of them, has this kind of text: text="???????????????????????????????????? ??????????????????????? ?????????????????????????????????? ????????????? ???????????????????? ?????? ? ? ???? ?????????????…
AlexMJ
  • 89
  • 1
  • 9
1 2 3
23
24