Results 1 to 9 of 9

Thread: Teach me some string parsing

  1. #1

    Default Teach me some string parsing

    I need to strip the leading space, all quotes, and the ] off this (example). I'm terrible at regex in general, so I'm sure someone can give me a quick Ruby function that will do this.

    "You sense that the drakar war mattock will persist after its last enhancive charge has been expended."]

  2. Default

    If you have a fixed format set of strings where you ALWAYS want to remove the first and last two characters, one of the simplest ways is string slicing.

    string = string[1..-3]

  3. Default

    Make sure to encrypt your strings.

  4. #4

    Default

    The strings are very static in their format, so this trick works. What's this about encrypting strings? I'm not a programmer... just trying to log my loresinging in a more useful format. Almost done going through the various permutations by modifying the iSing script. The output is looking like (example):

    Code:
     a monir-handled mithril halberd
    Weight = 8 lbs.
    value = about 200,000 silvers.
    Bonus of: +5 
    Flares = the power of an ice elemental
    5 to Agility who has trained 9 times
    3 to Polearm Weapons Ranks who has trained 12 times
    It has  a fair amount of charges  remaining.
    It spits it out into a log file. This lets me mindlessly loresing the dozens (possibly hundreds) of items found in DR that appraise for values worth loresinging, and not have to manually create everything in a readable format. I am probably going to ensure that there's a common delimiter at the end of each line, so I can easily import it into excel if I wanted and easily post tables for resale.

    This is still a work in progress, and my code is super hacked together garbage that any number of people on here could rip to shreds, but it gets the job done. Still haven't worked with any armor, so padding and temporary benefits (like bonus to TD) are not being parsed yet.
    Last edited by Maerit; 05-02-2017 at 03:35 PM.

  5. #5
    Join Date
    Jul 2003
    Location
    St. Louis, MO
    Posts
    4,271

    Default

    Check out of the loglore script in the repo that was recently uploaded and serves a similar purpose.

    For your example, here is a simple regex to capture the stuff you care about in the example string. Rubular is a very useful tool in general for testing text parsing with regular expressions, which are a pretty good hammer for most GS-related text processing tasks.
    Quote Originally Posted by Patrick McGoohan
    I am not a number, I am a free man!

  6. #6

    Default

    I'm getting this a lot with ising:

    --- Lich: DownstreamHook: unexpected return
    iSing:24:in `block in cmd_proc

  7. #7

    Default

    Quote Originally Posted by BigWorm View Post
    Check out of the loglore script in the repo that was recently uploaded and serves a similar purpose.

    For your example, here is a simple regex to capture the stuff you care about in the example string. Rubular is a very useful tool in general for testing text parsing with regular expressions, which are a pretty good hammer for most GS-related text processing tasks.
    Just checked out loglore, thanks for the tip. Found that it outputs a similar amount of information that iSing was outputting. I just want the stuff that most folks care about in very simple short sentences. It's a lot harder to sort through all the loresong verbage to get at the important details, and for merchants - that reduces sales!

    Like this is loglore output:

    Code:
    The harmonics generated tell you that the greaves serves to reduce the severity of inflicted wounds.  The magical harmonics reveal that arms are better protected when wearing the imflass arm greaves.
    The greaves resonates with your voice, revealing some details of its temporary enhancement:
    The greaves's enhancement will degrade when the wearer is struck in combat.
    It should be able to withstand an incredible amount of uses before its enhancement has completely degraded away.
    When its enhancement has degraded away, the item will lose its special ability.
    As your song penetrates the imflass arm greaves, you determine that it is moderately resistant to fiery attacks.
    All you need from this would be:

    Code:
    Temporary Critical Padding with Incredible charges
    Moderately resistant to fiery attacks
    The rest of it is fluff and just makes the log too long (IMO).
    Last edited by Maerit; 05-02-2017 at 03:53 PM.

  8. #8

    Default

    So, tonight, I messaged Dreaven to suggest he strip out the relevant code from his testme script to do the loresong logging.

    Surprise. It does already.

    Then I suggested he still strip it out so that it would only loresing ...

    ... and guess what? Yeah, it already does that too.

    ;testme <skip>

    skips over the zest testing and only loresings. It will log if you have enabled it.

    So people who are looking for logging might look at it. Please read the beginning of the script for instructions.
    Luxie's adventures (because I must write) plus some guests from the past at my blog:
    http://www.thebardess.com

  9. Default

    Yeah, Dreaven usually knows what I want my scripts to do before I do.

Similar Threads

  1. error in Gtk.queue: comparison of String with String failed
    By Daerkstar in forum The Lich Project
    Replies: 4
    Last Post: 09-11-2011, 07:27 AM
  2. Parsing LNET
    By Kaelozim in forum The Lich Project
    Replies: 4
    Last Post: 09-30-2010, 06:33 PM
  3. Log Parsing for Combat?
    By grapedog in forum General Gemstone
    Replies: 4
    Last Post: 07-25-2007, 04:00 PM
  4. string rightOf(string source, string r)
    By Jonty in forum Bug Reporting
    Replies: 0
    Last Post: 09-10-2004, 03:12 PM
  5. string replace(string source, string s, string r)
    By Jonty in forum Bug Reporting
    Replies: 0
    Last Post: 09-09-2004, 10:33 PM

Posting Permissions

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