Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Help with a Regex

by demerphq (Chancellor)
on May 07, 2005 at 11:14 UTC ( [id://454890]=note: print w/replies, xml ) Need Help??


in reply to Re: Help with a Regex
in thread Help with a Regex

M = 1000 and comes "first", D = 500 and comes "second", etc.

Sure, M is left most, and D is second left most. But your examples have contrary input. "XIX" => "....X.I" contradicts "IX" => "....X.." as far as I can tell.

---
$world=~s/war/peace/g

Replies are listed 'Best First'.
Re^3: Help with a Regex
by insaniac (Friar) on May 07, 2005 at 11:29 UTC
    well... i got some suckie code (just woke up with a terrible hangover... too much free beer ;-) )
    but i think i understand it a bit more now... take the input string, look for the highest value (first time it's M, second time it's D), and start looking from that position for the next highest value (skipping of course the previous highest one).

    for the suckie code, here's the output:
    I => ......I ( ......I : Ok ) IV => .....V. ( .....V. : Ok ) V => .....V. ( .....V. : Ok ) VI => .....VI ( .....VI : Ok ) IX => ....X.. ( ....X.. : Ok ) X => ....X.. ( ....X.. : Ok ) XI => ....X.I ( ....X.I : Ok ) XIV => ....XV. ( ....X.I : Not Ok) XV => ....XV. ( ....XV. : Ok ) XVI => ....XVI ( ....XVI : Ok ) XIX => ....X.I ( ....X.I : Ok ) X => ....X.. ( ....X.. : Ok ) XL => ....X.. ( ...L... : Not Ok) LX => ...LX.. ( ...LX.. : Ok ) XC => ....X.. ( ..C.... : Not Ok) CLXIX => ..CLX.I ( ..CLX.I : Ok ) CDXLVI => .D..XVI ( .D..XVI : Ok ) MCMXCVI => M.C.XVI ( M.C.XVI : Ok ) MDCLI => MDCL..I ( MDCL..I : Ok )
    I think i know what to do, but my code is not really working as I expected.. or maybe I should wait till my hangover is ... over ;-)

    to ask a question is a moment of shame
    to remain ignorant is a lifelong shame

Re^3: Help with a Regex
by planetscape (Chancellor) on May 12, 2005 at 10:18 UTC

    I believe I have finally vanquished the Demons of Derval Byslexia...

    What I posted: _______________ I ......I IV .....V. V .....V. VI .....VI IX ....X.. X ....X.. XI ....X.I XIV ....XV. XV ....XV. XVI ....XVI XIX ....X.I X ....X.. XL ....X.. WRONG Should be: ...L... LX ...LX.. XC ....X.. WRONG Should be: ..C.... CLXIX ..CLX.I CDXLVI .D..XVI WRONG Should be: .D.L.VI MCMXCVI M.C.XVI MDCLI MDCL..I _______________

    Revised

    Desired Output: _______________ I ......I IV .....V. V .....V. VI .....VI IX ....X.. X ....X.. XI ....X.I XIV ....XV. XV ....XV. XVI ....XVI XIX ....X.I X ....X.. XL ...L... LX ...LX.. XC ..C.... CLXIX ..CLX.I CDXLVI .D.L.VI MCMXCVI M.C.XVI MDCLI MDCL..I _______________

    Now for me to figure out which monk-contributed code works with the revised output... I'm blind now, so...

    Updated: Fixed two relatively minor typos.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://454890]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (1)
As of 2024-04-25 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found