Comments (3)
@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.
@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.
@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)
- does not work ie11 HOT 1
- IE problem HOT 1
- escape codes from `ansi-escapes` not being stripped by `strip-ansi`? HOT 4
- Set title mode escape codes not matched
- Allowing regex to match only first HOT 2
- developmemt HOT 3
- Does not work on terminal-link HOT 2
- fetchMetadata: sill resolveWithNewModule [email protected] checking installable status HOT 1
- IE11 not supported HOT 1
- Self-signed Certificate HOT 1
- Can't match cursorSave and cursorRestore HOT 3
- Backport of security patch, for benefit of yargs HOT 30
- Tests break (tsd) HOT 1
- Tests for CVE-2021-3807 HOT 2
- Error [ERR_REQUIRE_ESM]: Must use import to load ES Module HOT 3
- Yarn audit fails due to vulnrability HOT 1
- React [CRA] - Don't work with 5.0.1 HOT 2
- Some vim (or iTerm2?) ANSI sequences not fully consumed HOT 4
- 【正则匹配不全】 HOT 1
- This Library doesn't support CJS anymore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansi-regex.