Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re: This looks like someone sneezed and hit the keyboard by Sol-Invictus
in thread This looks like someone sneezed and hit the keyboard by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-06-22 09:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.