www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] Remove Ansi Escape Sequences?

  1. #1
    Join Date
    Jul 2007
    Posts
    357

    resolved [RESOLVED] Remove Ansi Escape Sequences?

    I'm working on getting information from a CLI app using regex. Of course, the program outputs stuff in colors. I need to remove the ansi escape seq. from it so I can I search it better. Any ideas?

  2. #2
    Join Date
    Jul 2007
    Posts
    357
    Ok here's what I have have at the moment:
    PHP Code:
    $subject preg_replace('/\x1B\[.*?;.*?;.*m(.*?)\[.*?;.*?;.*?m/'"$1",$subject); 
    For some reason - it's nuking most of the string that has a match...

  3. #3
    Join Date
    Jul 2007
    Posts
    357
    Ok -

  4. #4
    Join Date
    Jul 2007
    Posts
    357
    PHP Code:
        $subject preg_replace('/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/'"",$subject);
        
    $subject preg_replace('/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/'"",$subject);
        
    $subject preg_replace('/[\x03|\x1a]/'""$subject); 
    That looks like it works..Tested it against an ANS file. Will test against the CLI tonight.

  5. #5
    Join Date
    Jul 2007
    Posts
    357
    OK - it works with the CLI stuff (Asterisk if anyone wants to know)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles