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
2 answers

Lua pattern is not working properly when 0 is missing in the last row

below is my pattern which is working fine against the given string. local tempRec = [[ ABC01-USD-0322-A Total DUE amount : 2312.08 USD Value Date : 31 MAY 2011 Details:ABCDE - BCD: / ABC01 0212 23.79 / ARM01 0311 870.79 Details:FGHIJ -…
Shax
  • 4,207
  • 10
  • 46
  • 62
0
votes
1 answer

How to make a pattern in Lua that matches only when no number (normal or roman) is present?

I want to make a pattern that matches only when a string contains no arabic or roman numerals (note that the roman numerals can only go up to X (10)) Examples: "Rock" <-- matches "Rock IV" <-- doesn't match "Rock 4" …
joker876
  • 45
  • 1
  • 6
0
votes
2 answers

Lua REGEX, catch parenthesis

How catch the values (r = 32, g = 36, b = 51) from this data above? $color1: rgba(32, 36, 51, 1); I try: v = "$color1: rgba(32, 36, 51, 1);" id, r, g, b = v.match(v, "%$color(%d+)%:%s+rgba%((%d+)%,%s+(%d+)%,%s+(%d+)%,%s+%d+%)%;") or 0, 0, 0, 0 But…
Morogorn
  • 49
  • 1
  • 5
0
votes
1 answer

Lua not finding subsring

I have the same problem as lua string.find not recognising substring but I've tried the suggestions in it to no avail. local share_index = master_table[line_index] local string_dump =…
0
votes
0 answers

how split lines and get the pattern in lua?

I need in function,which do splitting of lines in lua. As i know,for splittings of lines by sep in lua i can use gmatch function,but i want to get sep in table to. For example,if i use pattern %s* and line 1 2 3 4, I expect getting table like:{1,…
0
votes
1 answer

Getting the time in the format HH:MM:SS between the current time and a time from Trello

I'm currently able to get the Trello due date, giving me this string: 2018-10-22T16:00:00.000Z I'd like to get the time until then in the format HH:MM:SS as a string. With normal Lua, I imagine it wouldn't be too hard, but with the restricted use…
0
votes
1 answer

LUA patterns to detect matching date

I struggling to find the correct LUA code to detect if two dates appear after each other. I have something similar which detects two keywords, but it's not working on my dates. Here's the LUA code I have so far: (%a+) %- %1$ Cheers,
greenage
  • 399
  • 3
  • 13
0
votes
2 answers

Lua Regex Functions declarations

I would like to parse all lua functions declarations from a lua file. For instance, let's assume I've got this code: function foo(a, b, c) local d = a + b local e = b - c return d *e end function boo(person) if (person.age == 18)…
x84x4
  • 19
  • 4
0
votes
1 answer

Lua pattern in mqtt topics

Here is a standard topic pattern which is used in mqtt. "lights/hue/{device_name}/get/sensing" How could I use the regular expression to format this topic pattern with a real device name. I am not very into the regular expression, so what I would…
user824624
  • 7,077
  • 27
  • 106
  • 183
0
votes
1 answer

Applying quantifier to a sentence in Lua pattern

So I am trying to parse out #define statements out of a C file using Lua patterns, but there is the case on multiline defines, where you might escape the newline character with a backslash. In order for me to know where the define ends, I need to be…
Luiz Berti
  • 1,421
  • 1
  • 15
  • 24
0
votes
1 answer

Lua Matching First-Level Tags Inside

I'm trying to get all first-level tags nested under head tag of any html response going through my reverse proxy. I'm running nginx+lua, so the solution in terms of lua pattern matching would be great... Right now I string.sub() the inside of head…
Alex L.
  • 101
  • 11
0
votes
1 answer

Trying to use match and gmatch string pattern matching functions in lua to parse an xml file but not getting the expected result

I want to parse and print specific data from an XML file using Lua. Here is a snippet from my XML code:
0
votes
1 answer

Lua: RegEx to Pattern

Simple problem...I need to turn this RegEx pattern... "\[\"([0-9]+)\"\]" into a Lua pattern. I am doing this to replace a bunch ["X"] lines with just [X] in a string where X is any number from -∞ or +∞...so that's about the only limitation. I need…
G.T.D.
  • 386
  • 1
  • 5
  • 21
0
votes
1 answer

How to split string using a whole word as separator?

Is there a way to split string like: "importanttext1 has gathered importanttext2 from stackoverflow." I want to grab anything before the word "has", and just want to grab the one word after "gathered", so it doesn't include "from stackoverflow.".…
0
votes
1 answer

How to split string in Lua with comma

I need separated string with limited string(for me comma) or char in array. How separated o split with comma in Lua. I check these links, but I don't…
rkv
  • 118
  • 2
  • 13
1 2 3
23
24