Author Topic: Feature request: regexp support for \n  (Read 3948 times)

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
Feature request: regexp support for \n
« on: January 10, 2005, 04:54:05 PM »
Pretty please? :D
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline SimDing0â„¢

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Feature request: regexp support for \n
« Reply #1 on: January 10, 2005, 04:55:59 PM »
Yeh, this'd be very useful.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Feature request: regexp support for \n
« Reply #2 on: January 10, 2005, 04:58:42 PM »
What is regexp \n?
I ask since I want to start thinking of possible uses before Wes codes it.   :)
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Ghreyfain

  • PPG
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: Feature request: regexp support for \n
« Reply #3 on: January 10, 2005, 05:00:42 PM »
Line break, as I understand it.
Earn Money Sleeping.

Offline SConrad

  • Spellhold Director
  • Planewalker
  • *****
  • Posts: 130
  • Gender: Male
  • WeiDU (ab)user
    • Spellhold Studios
Re: Feature request: regexp support for \n
« Reply #4 on: January 10, 2005, 05:04:33 PM »
I'm with Cam and Sim.
sconrad.net

jcompton: "When did the switch flip in your brain that made this make sense to you?"

Spellhold Studios - Where the switch flipped in our brains that made things make sense!

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
Re: Feature request: regexp support for \n
« Reply #5 on: January 10, 2005, 06:06:21 PM »
Yes, \n is a line break.
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline Rastor

  • Planewalker
  • *****
  • Posts: 271
  • Author of the book, "Being a Jerk for Dummies"
    • RPG Dungeon
Re: Feature request: regexp support for \n
« Reply #6 on: January 11, 2005, 06:43:16 AM »
Could you provide a for instance of just when you would use this?

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
Re: Feature request: regexp support for \n
« Reply #7 on: January 11, 2005, 07:12:59 AM »
Code: [Select]
COPY_EXISTING_REGEXP GLOB %.*.dlg$% %override%
  DECOMPILE_DLG_TO_D
    REPLACE_TEXTUALLY %DO ~ \|\n*~% %%
  COMPILE_D_TO_DLG
  BUT_ONLY_IF_IT_CHANGES

Thi would fix all of the dialogues that NI reports as corrupt due to empty DO ~~ actions. The problem lies in that the DO ~~ actions often contain line breaks, i.e. they decompile as

Code: [Select]
  IF ~~ THEN DO ~
~ EXIT
END

Sim has also identified places where it could be used for better script patching.
« Last Edit: January 11, 2005, 07:14:37 AM by CamDawg »
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline Rastor

  • Planewalker
  • *****
  • Posts: 271
  • Author of the book, "Being a Jerk for Dummies"
    • RPG Dungeon
Re: Feature request: regexp support for \n
« Reply #8 on: January 11, 2005, 12:21:51 PM »
Code: [Select]
COPY_EXISTING_REGEXP GLOB %.*.dlg$% %override%
  DECOMPILE_DLG_TO_D
    REPLACE_TEXTUALLY %DO ~ \|\n*~% %%
  COMPILE_D_TO_DLG
  BUT_ONLY_IF_IT_CHANGES

Thi would fix all of the dialogues that NI reports as corrupt due to empty DO ~~ actions. The problem lies in that the DO ~~ actions often contain line breaks, i.e. they decompile as

Code: [Select]
  IF ~~ THEN DO ~
~ EXIT
END

Sim has also identified places where it could be used for better script patching.

Ah, okay.  I would like to see this feature implemented as well.

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Feature request: regexp support for \n
« Reply #9 on: January 11, 2005, 03:10:51 PM »
Thi would fix all of the dialogues that NI reports as corrupt due to empty DO ~~ actions.
Support for whitespace (\s) would be better for this.

Of course, if that gets added, I'd have to voice my support for \S (!whitespace), \w ("word"), \W (!"word"), \d (digit), and \D (!digit).
« Last Edit: January 11, 2005, 03:16:28 PM by devSin »

Offline SimDing0â„¢

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Feature request: regexp support for \n
« Reply #10 on: January 11, 2005, 03:37:35 PM »
Actually, I suspect both \n and \s would be useful for script patching if WeiDU decompiles scripts with indentation.

Offline japheth

  • PPG
  • Planewalker
  • *****
  • Posts: 143
Re: Feature request: regexp support for \n
« Reply #11 on: January 12, 2005, 02:15:52 PM »
The $ metacharacter won't work for end line?  (Maybe Ocaml's $ metacharacter only recognizes \r or something?)

Anyways, I found this library: http://www.oefai.at/~markus/home/ocaml_sources.html (PCRE-Ocaml)

PCRE is way better than the standard Regex library.  And I don't think it should be too much trouble for Wes to implement.

Offline weimer

  • Moderator
  • Planewalker
  • *****
  • Posts: 2222
  • Gender: Male
    • WeiDU and Weimer Mods
Re: Feature request: regexp support for \n
« Reply #12 on: January 13, 2005, 11:42:15 PM »
Just to make sure I'm following along, the only concrete use suggested for this is to fix a false warning given by another tool for files present in the original game? :-)

No quick fix for this one guys, sorry. PRCE would be the right way to go about it, but I'm worried about backwards compatibility and file size bloat.

Offline SimDing0â„¢

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Feature request: regexp support for \n
« Reply #13 on: January 14, 2005, 06:07:01 AM »
Well...

I believe really the question I should be asking is "can multiple lines of a script be patched reliably without a regexp?"

Let's say I want to do a fix for all the occurances of Spell(Blah,0) in game scripts. There are... quite a few of these, so using REPLACE_BCS_BLOCK is not a terribly compelling suggestion.
Now let's take the script... DEGARD2.BCS. There are two different occurances of HaveSpell(0), which should cast DIFFERENT spells. Therefore, a simple REPLACE_TEXTUALLY of this line is out. What I could do though is take the other lines around it too. So,
Code: [Select]
COPY_EXISTING ~DEGARD2.BCS~ ~override~
DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY "!General(LastSeenBy(Myself),HUMANOID)
HaveSpell(0)" "!General(LastSeenBy(Myself),HUMANOID)
HaveSpell(WIZARD_HOLD_MONSTER)"
COMPILE_BAF_TO_BCS
But, I'm not sure how reliable this would be to use, since I had issues with REPLACE_TEXTUALLY failing on multiple DLG file actions... issues which were solved by adding a regexp inbetween the actions, if you recall.

Support for multiple lines in script patching like this, if it's not already there, would greatly improve the possibilities for script patching, and pretty much make REPLACE_BCS_BLOCK obsolete, which would thrill me to bits because I've always found it rather clunky. If the solution's just "copy/paste several lines straight out the BAF and it'll always work", then, uh, sorry. :)
« Last Edit: January 14, 2005, 06:08:38 AM by SimDing0â„¢ »

Offline SimDing0â„¢

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Feature request: regexp support for \n
« Reply #14 on: January 14, 2005, 06:19:36 AM »
Incidentally, perhaps slightly less elegant solution to Cam's might be to have WeiDU compile empty DO statements as no action, rather than putting the empty action back in the DLG, which is I assume what it does.

Offline weimer

  • Moderator
  • Planewalker
  • *****
  • Posts: 2222
  • Gender: Male
    • WeiDU and Weimer Mods
Re: Feature request: regexp support for \n
« Reply #15 on: January 14, 2005, 09:21:09 AM »
DO ~foo~ where ~foo~ contains no letters or number (i.e., is all whitespace) are now compiled to "no action".

Offline SimDing0â„¢

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Feature request: regexp support for \n
« Reply #16 on: January 14, 2005, 04:51:53 PM »
That sounds great, thanks. Any thoughts on the script patching issue I mentioned though?

Offline SimDing0â„¢

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Feature request: regexp support for \n
« Reply #17 on: January 19, 2005, 02:58:45 PM »
:)

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6253
  • Gender: Female
  • The perfect moment is now.
Re: Feature request: regexp support for \n
« Reply #18 on: July 12, 2007, 02:36:53 AM »
Please, forgive this bit of necromancy, but has this been implemented? WeiDU Changes Log doesn't reflect anything of the kind, and I think there's still demand for this one - this stuff, for example.

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
Re: Feature request: regexp support for \n
« Reply #19 on: July 12, 2007, 07:09:11 AM »
What, support for \n? No, but there are workarounds--take a look at the extra_regexp_vars.tph library from Fixpack (credit where credit's due: thank the bigg), it adds support for matching new lines and tabs via regexp.
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6253
  • Gender: Female
  • The perfect moment is now.
Re: Feature request: regexp support for \n
« Reply #20 on: July 12, 2007, 07:18:36 AM »
[%tab%%lnl%%mnl%%wnl%]? Thank you, I will try it.

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6253
  • Gender: Female
  • The perfect moment is now.
Re: Feature request: regexp support for \n
« Reply #21 on: July 12, 2007, 07:47:03 AM »
Oh. I realized I didn't need it in the first place, since Fixpack seemed to get away with stuff like this:

Code: [Select]
REPLACE_TEXTUALLY ~^7\( .+ + .+ + .+ + .+ + .+ + .+ + .+\)~
~6\1
7\1~

Never mind me, I'm just a piano player.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: