lua Gsub

Hi there,

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 23:12:08    

print(string.gsub(s, “%<!.-%!>”)) doesnt work 

2. 

I would need all the text WITHOUT the date/time like:

this is a test string. something more"

thanks a lot !

how about:

string.gsub(s, "(.\*)\<!.\*!\>(.\*)", print)

thanks !! :slight_smile:

thats very cool.

I saw when i do

s=“this is a test string. <!2014-05-03 23:12:08!> something more”

string.gsub(s, “<!.*!>”, print)

i would get only the date

but HOW would I assign that result to a variable

new  = string.gsub(s, “<!.*!>”, print)

does not work.

so just the date and nothing else

thanks

chris

how about:

string.gsub(s, "(.\*)\<!.\*!\>(.\*)", print)

thanks !! :slight_smile:

thats very cool.

I saw when i do

s=“this is a test string. <!2014-05-03 23:12:08!> something more”

string.gsub(s, “<!.*!>”, print)

i would get only the date

but HOW would I assign that result to a variable

new  = string.gsub(s, “<!.*!>”, print)

does not work.

so just the date and nothing else

thanks

chris