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

Re: This looks like someone sneezed and hit the keyboard

by Sol-Invictus (Scribe)
on Feb 03, 2004 at 10:54 UTC ( [id://326162]=note: print w/replies, xml ) Need Help??


in reply to This looks like someone sneezed and hit the keyboard

this is expecting to parse a command line prompt which uses ANSI escapes:
ANSI Color Codes in brief: 0 to restore default color 1 for brighter colors 4 for underlined text 5 for flashing text 30 for black foreground 31 for red foreground 32 for green foreground 33 for yellow (or brown) foreground 34 for blue foreground 35 for purple foreground 36 for cyan foreground 37 for white (or gray) foreground 40 for black background 41 for red background 42 for green background 43 for yellow (or brown) background 44 for blue background 45 for purple background 46 for cyan background 47 for white (or gray) background you use the above codes together with an escape sequence like this (re +place the '#' with the colour code of your choice) : \e[#m Once you've used an escape all subsequent text will be affected until +you use the reset escape \e[0m so if I want to format a part of a line of text, instead of: print "This boring old line of text was supposed to have red text\n"; do this: print "This new improved, brighter, more interesting line of text has +\e[31mred text\e[0m\n" ; If you want to use two escapes on the same piece of text use one of these ';' : \e[#;#m print "This \e[5m new improved \e[0m, \e[5m brighter \e[0m, more \e[5minteresting \e[0m line of text has \e[31;5mflashing red text\e[0m\n" ;

\e[0m (the reset string) requires escaping in the regex, or at least the '\' and '[' do. In pseudo code the regex would read like this :

match anything (.*) grab the rest up to \e[0m

try running it on the couple of the ANSI formatted strings I gave as examples and you'll see how it's working

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-25 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found