Starfinder Playlist
  1. #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);
    (note the bold sections that will be missing in later examples)

    Trying to match this:
    Code:
    					<p>Links here:</p>
    					<linklist>
    						<link class="imagewindow" recordname="image.id-00003">wizard-token</link>
    					</linklist>
    The pattern would match in FGC but not FGU.

    Then I tried changing the FGU pattern matching to:
    Code:
    local nStart, nEnd = string.find(sNoteText,'<linklist><link class="imagewindow" recordname="[^\"]+">[^<]+</link></linklist>',1);
    At which point it matched in FGU... which seems to indicate that the "newline"chars in FGU are somehow ignored/removed/something.
    ---
    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.

  2. #2
    Also, since in your example the "<link" is indented, wouldn't that mean that the whitespace was also ignored/removed/something?

  3. #3
    Quote Originally Posted by gamerhawaii View Post
    Also, since in your example the "<link" is indented, wouldn't that mean that the whitespace was also ignored/removed/something?
    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>'
    FGU console log looks like this:
    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>'
    As you can see, the FGU version doesn't have the actual newlines.
    ---
    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.

  4. #4
    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

  5. #5
    Quote Originally Posted by Moon Wizard View Post
    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
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in