-
October 22nd, 2020, 15:19 #1
LUA Pattern matching issue with FGU versus FGC
I posted this in the Workshop but this should go here.
I noticed when parsing text from story entries that in FGC I would get a different result than if I ran it in FGU (same code).
The pattern match was this:
Code:local sNoteText = DB.getValue(nodeStory,"text",""); local nStart, nEnd = string.find(sNoteText,'<linklist>[^<]+<link class="imagewindow" recordname="[^\"]+">[^<]+</link>[^<]+</linklist>',1);
Trying to match this:
Code:<p>Links here:</p> <linklist> <link class="imagewindow" recordname="image.id-00003">wizard-token</link> </linklist>
Then I tried changing the FGU pattern matching to:
Code:local nStart, nEnd = string.find(sNoteText,'<linklist><link class="imagewindow" recordname="[^\"]+">[^<]+</link></linklist>',1);
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
October 22nd, 2020, 16:24 #2
- Join Date
- May 2007
- Posts
- 84
Also, since in your example the "<link" is indented, wouldn't that mean that the whitespace was also ignored/removed/something?
-
October 22nd, 2020, 17:11 #3
That's just how the xml file was formatted I copied it from.
FGC console log looks like this:
Code:Runtime Notice: s'manager_author_adnd.lua' | s'createBlocks' | s'sNoteText' | s' <p>Links here:</p> <linklist> <link class="imagewindow" recordname="image.id-00003">wizard-token</link> </linklist>'
Code:[10/22/2020 11:09:59 AM] s'manager_author_adnd.lua' | s'createBlocks' | s'sNoteText' | s'<p>Add links below.</p><linklist><link class="imagewindow" recordname="image.id-00002">Image tsr</link></linklist>'
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
October 22nd, 2020, 22:50 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,571
The fragment support for the XML engine in FGU is different, and writes it in a more concise format.
Have you tried using '*', instead of '+' for matching in between tags?
local nStart, nEnd = string.find(sNoteText,'<linklist>[^<]*<link class="imagewindow" recordname="[^\"]+">[^<]+</link>[^<]*</linklist>',1);
Regards,
JPG
-
October 23rd, 2020, 08:15 #5
My memory recall suggests that when I tried that originally it would capture "<linklist>*"... and matching everything after that no matter what. I'll test it tomorrow and see if my memory is correct.
For now, what I've done is create 2 patterns, one for FGC and one for FGU. Based on the version running it uses the correct one. I posted here as you had once said you'd like to see reports on different behaviors between FGC/FGU.Last edited by celestian; October 23rd, 2020 at 08:18.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks