lua-patterns Questions

3

Is there a way I can do a string pattern that will match "ab|cd" so it matches for either "ab" or "cd" in the input string. I know you use something like "[ab]" as a pattern and it will match for e...
Novah asked 6/10, 2013 at 21:51

1

Solved

I apply a function, but looks so bad. function find_without_pattern(s1,s2) for i =1,#s1-#s2+1 do local t = string.sub(s1,i,#s2+i-1) if t == s2 then return i,i+#s2-1 end end end
Dimenhydrinate asked 24/9, 2013 at 4:33

3

Solved

Suppose I am inserting a string into a table as follows: table.insert(tbl, mystring) and that mystring is generated by replacing all occurrences of "a" with "b" in input: mystring = string.gsub...
Hourigan asked 24/4, 2010 at 14:22

1

Solved

I am trying to remove '$' signs from a string, but I am guessing it is some special char? I am extremely new to lua (just started coding in it today). From my understanding this should work and doe...
Heliotrope asked 13/9, 2013 at 16:47

1

Solved

I'm using Lua string.match to extract some values of a HTML but I'm having some problems with some attributes. To extract a phone number like this: 0000-0000, I'm using the mask: local value = st...
Inhospitable asked 2/9, 2013 at 0:23

1

Solved

How do I get the file name from a URL using Lua string manipulations. I have this url https://thisisarandomsite.com/some_dir/src/blah/blah/7fd34a0945b036685bbd6cc2583a5c30.jpg And I want to get ...
Carolus asked 16/8, 2013 at 2:9

4

Solved

I have a string I need to add a variable to so I use the string.format method, but the string also contains the symbol "%20" (not sure what it represents, probably a white space or something). Anyw...
Jinnah asked 8/8, 2013 at 13:36

3

Solved

I'm trying to do a library in Lua with some function that manipulate strings. I want to do a function that changes the letter case to upper only on odd characters of the word. This is an example: ...
Nobel asked 7/8, 2013 at 12:20

2

Solved

In Lua there's only string.find, but sometime string.rfind is needed. For example, to parse directory and file path like: fullpath = "c:/abc/def/test.lua" pos = string.rfind(fullpath,'/') dir = st...
Pomegranate asked 30/6, 2013 at 3:16

3

I'm trying to make a simple string manipulation: getting the a file's name, without the extension. Only, string.find() seem to have an issue with dots: s = 'crate.png' i, j = string.find(s, '.') p...
Freida asked 6/3, 2013 at 21:21

3

Solved

I have a standard Windows Filename with Path. I need to split out the filename, extension and path from the string. I am currently simply reading the string backwards from the end looking for . to...
Rafael asked 9/3, 2011 at 8:41

2

Solved

I'm trying to match a string against a pattern, but there's one thing I haven't managed to figure out. In a regex I'd do this: Strings: en eng engl engli englis english Pattern: ^en(g(l(i(s(h?)?)...
Kyrstin asked 6/7, 2012 at 14:42

1

Solved

English isn't my mother tongue,so it's a little hard to describe the question. I wanna to get 'd=40' in str by lua string.gsub(),but there's some problem. ------code below--- local str = [==[ ...
Ordure asked 14/4, 2012 at 18:32

1

Solved

I'm starring at these few (slightly modified) lines from luadoc that are obviously building a filename with a full path. But I simply don't get it what happens in line 5. The parameter filename cou...
Libb asked 15/4, 2011 at 17:9

4

Solved

I've been playing with this for an hour or tow and have found myself at a road block with the Lua pattern matching utilities. I am attempting to match all quoted text in a string and replace it if ...
Top asked 30/11, 2010 at 18:50

1

Solved

How would i do this? I got this: name = "^aH^ai" string.gsub(name, "^a", "") which should return "Hi", but it grabs the caret character as a pattern character What would be a work around for ...
Shang asked 28/11, 2010 at 16:5

© 2022 - 2024 — McMap. All rights reserved.