Giter Club home page Giter Club logo

Comments (3)

sindresorhus avatar sindresorhus commented on June 11, 2024

@arjunmehta hah, coincidence. I noticed this just today too that there's a LOT of various ways to create ansi escape codes. I should have looked it up sooner and not just gone by assumption.

Any help welcome :)

from ansi-regex.

arjunmehta avatar arjunmehta commented on June 11, 2024

@sindresorhus That's funny! Yes there are many different ANSI codes and there are likely a few ways of dealing with this.

I asked a question on Stack Overflow about an algorithmic solution yesterday as I was trying to find an effective way of dealing with the problem. I'm not the best at asking Stack Overflow questions and it got downvoted for some reason, but there were a couple really great answers which came out of it which I tweaked a bit. One of the authors of an answer started a jsperf which I tweaked a bit.

Regex is a really slow way of doing this (and so the name of the module may have locked in the solution :P) but looping through the string is more efficient, apparently.

The other way is to create a table of characters/character codes and deal with them that way.

from ansi-regex.

arjunmehta avatar arjunmehta commented on June 11, 2024

@sindresorhus I found a much better regex to use.

I'm working on some scripts that help test/reveal which of the listed VT100 codes the regex will match, and which ones won't match.

I'll send a pull request that includes the new regex and additions to the test which ought to help test in the future for other codes.

from ansi-regex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.