for line in string.gfind [lua]

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

Post Reply
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

for line in string.gfind [lua]

Post by Luk4ward »

hello,

i have a question about capturing data using this for...I got a file with lines:

Code: Select all

# <- ignore this line
# # is for comment
Hex string with 32 length=blabla
Hex string with 32 length=blabla
Hex string with 32 length=blabla
Hex string with 32 length=blabla
Hex string with 32 length=blabla
Hex string with 32 length=blabla
Hex string with 32 length=blabla
Hex string with 32 length=blabla
Hex string with 32 length=blabla
I want to capture only and exactly the hex string the rest i want to ignore and switch to next line etc.

when im using:

Code: Select all

for hex, comment in string.gfind&#40;filestr, "&#40;&#91;^\r\n#=&#93;%x+&#41;=&#40;&#91;^#=&#93;+&#41;"&#41; do

... smth

print hex
print comment

end
im getting:

Code: Select all

hex&#58; some hex <- matched
comment&#58; blabla
some hex <- why here ?
hex&#58; some hex <- matched
comment&#58; blabla
some hex <- why here ?
hex&#58; some hex <- matched
comment&#58; blabla
some hex <- why here ?
hex&#58; some hex <- matched
comment&#58; blabla
some hex <- why here ?
hex&#58; some hex <- matched
I gave up, i really hate those capturing. Please for help and thx in advance
wolFTeam.pl
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

probely becase the comment match not only the command but also the \n and the hex at the next line until it finds a new #

try

Code: Select all

for hex, comment in string.gfind&#40;filestr, "&#40;&#91;^\r\n#=&#93;%x+&#41;=&#40;&#91;^\r\n#=&#93;+&#41;"&#41; do
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

=FF=im2good4u wrote:probely becase the comment match not only the command but also the \n and the hex at the next line until it finds a new #

try

Code: Select all

for hex, comment in string.gfind&#40;filestr, "&#40;&#91;^\r\n#=&#93;%x+&#41;=&#40;&#91;^\r\n#=&#93;+&#41;"&#41; do
many thx, seems to work, when i finish the script ill publish it on etpro:mods,

regards
wolFTeam.pl
Post Reply