Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Nov 22, 2008 11:28 pm   

Regex Pattern Ignoring Something It SHOULD Pick Up (Though I may be wrong...)
 
Ok, here is the text I'm working on (I know Rift regexes have been visited MANY times)

Code:
Glancing into the Rift, you see:
 [ 489] bayberry bark      [ 419] bellwort flower    [ 523] black cohosh
 [ 236] bloodroot leaf     [   2] blue ink           [   5] blueberry
 [  10] cloth              [  22] eagle's feather    [ 361] echinacea
 [ 579] ginger root        [  81] ginseng root       [ 256] goldenseal root
 [ 340] hawthorn berry     [ 139] irid moss          [ 219] kelp
 [ 457] kola nut           [ 207] kuzu root          [ 267] lady's slipper
 [ 350] lobelia seed       [ 295] myrrh gum          [ 438] prickly ash bark
Type MORE to continue reading. (66% shown)
more
2261h, 2318m, 10184e, 12590w exdb-
 [ 266] prickly pear       [   4] red ink            [  22] rope
 [  12] sidewinder skin    [ 130] sileris            [ 364] skullcap
 [ 284] slippery elm       [ 267] valerian           [  34] venom sac
 [   6] weed               [  93] wood
2261h, 2318m, 10184e, 12590w exdb-


Now, I'm using this regex to capture the lines, but it is ignoring sileris and valerian. And I cannot explain why. So, any help is appreciated.
Code:
^\s*\[\s*(\d+)\] ([\w' ]+)\s*(?:\[\s*(\d+)\] ([\w' ]+)\s*)?(?:\[\s*(\d+)\] ([\w' ]+)\s*)?
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Nov 22, 2008 11:31 pm   
 
Here is what I see (I'm #ECHO'ing anything the trigger detects for testing purposes)

Code:
~~~snip~~~
[ 266] prickly pear       [   4] red ink            [  22] rope
Adding prickly pear
Adding red ink
Adding rope
[  12] sidewinder skin    [ 130] sileris            [ 364] skullcap
Adding sidewinder skin
Adding skullcap
[ 284] slippery elm       [ 267] valerian           [  34] venom sac
Adding slippery elm
Adding venom sac
[   6] weed               [  93] wood
Adding weed
Adding wood
2261h, 2318m, 10184e, 12590w exdb-
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Nov 23, 2008 1:43 am   
 
Not sure why it's not working for you. I just ran a test:

Code:
[ 489] bayberry bark [ 419] bellwort flower [ 523] black cohosh
Adding bayberry bark
Adding bellwort flower
Adding black cohosh
[ 236] bloodroot leaf [   2] blue ink [   5] blueberry
Adding bloodroot leaf
Adding blue ink
Adding blueberry
[  10] cloth [  22] eagle's feather [ 361] echinacea
Adding cloth
Adding eagle's feather
Adding echinacea
[ 579] ginger root [  81] ginseng root [ 256] goldenseal root
Adding ginger root
Adding ginseng root
Adding goldenseal root
[ 340] hawthorn berry [ 139] irid moss [ 219] kelp
Adding hawthorn berry
Adding irid moss
Adding kelp
[ 457] kola nut [ 207] kuzu root [ 267] lady's slipper
Adding kola nut
Adding kuzu root
Adding lady's slipper
[ 350] lobelia seed [ 295] myrrh gum [ 438] prickly ash bark
Adding lobelia seed
Adding myrrh gum
Adding prickly ash bark
Type MORE to continue reading. (66% shown)
more
2261h, 2318m, 10184e, 12590w exdb-
[ 266] prickly pear [   4] red ink [  22] rope
Adding prickly pear
Adding red ink
Adding rope
[  12] sidewinder skin [ 130] sileris [ 364] skullcap
Adding sidewinder skin
Adding sileris
Adding skullcap
[ 284] slippery elm [ 267] valerian [  34] venom sac
Adding slippery elm
Adding valerian
Adding venom sac
[   6] weed [  93] wood
Adding weed
Adding wood


As you can see, it matched everything, using the same trigger pattern you are *shrug* Check all your triggers and make sure you don't have one that counters this one would be the only suggestion I have at this point.

Charneus

EDIT: I changed something in the value of the trigger to see if I can match it to your output, and I succeeded, oddly enough. Here's a second output of the same test:

Code:
[ 489] bayberry bark      [ 419] bellwort flower    [ 523] black cohosh
Adding bayberry bark
Adding bellwort flower
Adding black cohosh
[ 236] bloodroot leaf     [   2] blue ink           [   5] blueberry
Adding bloodroot leaf
Adding blue ink
Adding blueberry
[  10] cloth              [  22] eagle's feather    [ 361] echinacea
Adding eagle's feather
Adding echinacea
[ 579] ginger root        [  81] ginseng root       [ 256] goldenseal root
Adding ginger root
Adding ginseng root
Adding goldenseal root
[ 340] hawthorn berry     [ 139] irid moss          [ 219] kelp
Adding hawthorn berry
Adding irid moss
Adding kelp
[ 457] kola nut           [ 207] kuzu root          [ 267] lady's slipper
Adding kola nut
Adding kuzu root
Adding lady's slipper
[ 350] lobelia seed       [ 295] myrrh gum          [ 438] prickly ash bark
Adding lobelia seed
Adding myrrh gum
Adding prickly ash bark
Type MORE to continue reading. (66% shown)
more
2261h, 2318m, 10184e, 12590w exdb-
[ 266] prickly pear       [   4] red ink            [  22] rope
Adding prickly pear
Adding red ink
Adding rope
[  12] sidewinder skin    [ 130] sileris            [ 364] skullcap
Adding sidewinder skin
Adding skullcap
[ 284] slippery elm       [ 267] valerian           [  34] venom sac
Adding slippery elm
Adding venom sac
[   6] weed               [  93] wood
Adding wood


As you can see, it missed parameter 4 completely on two of the last three lines and parameter 2 on the last line... It even missed cloth on one of the other lines, too. Weird. I'll see what I can come up with.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sun Nov 23, 2008 1:11 pm   
 
Code:
^ \[\s{0,3}(\d+)\] ((?:[\w']+ ??){1,4})\s*+(?:\[\s{0,3}(\d+)\] ((?:[\w']+ ??){1,4})\s*+(?:\[\s{0,3}(\d+)\] ((?:[\w']+ ??){1,4})\s*+)?)?
The first space is always a single space there is no reason to use an * on it.

The spaces between the [ and \d can only be in the range of 0,3; backtracking is reduced by actually expressing it that way. The acceleration is likely extremely small, but considering the number of \s* in the pattern it makes good sense.

There has to be 2 entries on a line before there can be 3, so nest the optional parts.

"[\w' ]+" would want to pick up all the spaces with the words until the next "[" the \s* shouldn't have aproblem with it, but it can cause confusion to the regex engine. I reexpressed that as "(?:[\w']+ ){1,4}", then examined the need for \s* to still follow. Finding it need to be there the "??" was added to the space to make it self trimming and place the preference for the space to not be matched with the words. At the same time I added possesiveness to the \s so it would try to grab away that trailing space.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Nov 23, 2008 1:52 pm   
 
Vij, using it with the \* for offline testing (spaces don't always echo when I enter lines on the comman line) But other than that I don't see why my regex didn't work. Might not have been the most efficient, but whenever I put in one of the lines that has something on it being ignored into the Test box it properly reads the line. So I'm not sure what else is wrong. I'll try your pattern anyways and see if it helps.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net