lua-patterns Questions

4

Solved

Is it possible to achieve in Lua? local noSlashEnding = string.gsub("slash\\ending\\string\\", "\\|/$", "") -- noSlashEnding should contain "slash\\ending\\string" local noSlashEnding2 = string.g...
Poona asked 11/8, 2010 at 20:9

6

Solved

Given a multiline string with some blank lines, how can I iterate over lines in Lua including the blank lines? local s = "foo\nbar\n\njim" for line in magiclines(s) do print( line=="" and "(blank...
Warhorse asked 11/10, 2013 at 20:5

4

Solved

I'm able to capitalize the first letter of my string using: str:gsub("^%l", string.upper) How can I modify this to capitalize the first letter of every word in the string?
Eros asked 29/11, 2013 at 11:18

2

Solved

I am new to Lua, and hardly understand pattern matching. I am trying to figure out how to match everything in a string after a colon, and put that portion of the string into a variable. I haven't h...
Wormwood asked 17/5, 2018 at 16:48

4

Solved

I'm currently learning lua. regarding pattern-matching in lua I found the following sentence in the lua documentation on lua.org: Nevertheless, pattern matching in Lua is a powerful tool and inc...
Edveh asked 22/4, 2010 at 18:18

3

Solved

There are some discussions here, and utility functions, for splitting strings, but I need an ad-hoc one-liner for a very simple task. I have the following string: local s = "one;two;;four" And ...
Crosslink asked 11/11, 2013 at 13:45

3

Solved

In regex, | is used for alternation. What is the corresponding character in Lua patterns?
Phytogeography asked 3/5, 2012 at 19:48

4

I am working on renaming the Movie titles that has unwanted letters. The string.gsub can replace a string with "" nil value but I have around 200 string patterns that need to be replaces with "". ...
Cusped asked 13/8, 2014 at 7:25

3

Solved

Is there any way to replace a character at position N in a string in Lua. This is what I've come up with so far: function replace_char(pos, str, r) return str:sub(pos, pos - 1) .. r .. str:sub(p...
Devries asked 9/3, 2011 at 17:21

3

A simple pattern should do the job but I can't come up with/find something that works. I am looking to have something like this: lines = string.gmatch(string, "^\r\n")
Middlebuster asked 29/9, 2015 at 14:48

4

Solved

I am trying to extract the characters from a string of a word in Slovak. For example, the word for "TURTLE" is "KORYTNAČKA". However, it skips over the "Č" character when I try to extract it from t...
Peltry asked 9/4, 2014 at 6:0

3

Solved

I need to extract domain (four.five) from URL (one.two.three.four.five) in a Lua string variable. I can't seem to find a function to do this in Lua. EDIT: By the time the URL gets to me, the ht...
Salto asked 12/9, 2013 at 22:0

1

Solved

I have an xml page that I have a monitoring system scanning, here is the source data: `<queues> <queue name="workQueue"> <stats size="0" consumerCount="28" enqueueCount="29320" dequ...
Fpc asked 31/3, 2016 at 11:22

1

Solved

I'm looking for amount of repetitions of symbols in Lua pattern setup. I try to check amount of symbols in a string. As I read in manual, Even with character classes this is still very limiting, b...
Almonte asked 1/10, 2015 at 9:31

2

Solved

not sure how to check if a word appears as a whole word in a string, not part of a word, case sensitive. for example: Play is in strings Info Playlist Play pause but not in the strings Info Pl...
Dissimilar asked 29/9, 2015 at 19:51

1

Solved

I have a string similar to this: [13:41:25] [100:Devnull]: 01:41:20, 13:41:21> |Hunit:Player-3693-07420299:DevnullYour [Chimaera Shot] hit |Hunit:Creature-0-3693-1116-3-87318-0000881AC4:Dungeon...
Dagnah asked 19/3, 2015 at 20:49

3

Solved

So I have the following code to split a string between whitespaces: text = "I am 'the text'" for string in text:gmatch("%S+") do print(string) end The result: I am 'the text' But I need to d...
Spartan asked 22/2, 2015 at 22:35

2

Solved

str = "fa, (captured)[asd] asf, 31" for word in str:gmatch("\(%a+\)") do print(word) end Hi! I want to capture a word between parentheses. My Code should print "captured" string. lua: /home...
Avestan asked 9/10, 2014 at 11:34

2

Solved

I am trying to parse chemical formulas in Lua using simple pattern matching. However, I do not know how to specify a capture group as being optional. Here is the pattern I have come up with: patte...
Limekiln asked 25/9, 2014 at 17:45

1

Solved

How do you replace a dollar sign in Lua since it is a special character in pattern matching? I've tried this: string.gsub("$44,000.00", "$", "") > "$44,000.00" But all it does is add a blank...
Ornis asked 16/6, 2014 at 13:51

3

I haven't been able to find documentation of which characters compound the punctuation set "%p" in Lua.
Saxe asked 13/6, 2014 at 0:47

1

Solved

How would I extract in Lua a text between a pattern. For example s="this is a test string. <!2014-05-03 23:12:08!> something more" I would need only the date/time as result: 2014-05-03 2...
Brahma asked 19/5, 2014 at 3:9

1

Solved

I am trying to implement a pattern in Lua but no success The pattern I need is like regex: [a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12} which is to validate guid. I am not able ...
Occupancy asked 11/4, 2014 at 13:27

2

Solved

When answering this question, I wrote this code to iterate over the UTF-8 byte sequence in a string: local str = "KORYTNAČKA" for c in str:gmatch("[\0-\x7F\xC2-\xF4][\x80-\xBF]*") do print(c) e...
Amaral asked 9/4, 2014 at 7:52

2

Solved

Is it possible to substitute characters according to a list in Lua, like tr in Perl? For example, I would like to substitute A to B and B to A (e.g. AABBCC becomes BBAACC). In Perl, the solution w...
Dickey asked 5/11, 2013 at 4:57

© 2022 - 2024 — McMap. All rights reserved.