GithubHelp home page GithubHelp logo

Comments (11)

tricinel avatar tricinel commented on June 22, 2024 1

Ok, great! I can see use cases here, so I'm going to do it.

from highlight-words.

tricinel avatar tricinel commented on June 22, 2024 1

Hey @eriknyk, thanks for trying it out!

Could you try this:

stacktraceChunks = highlightWords({
  text: item.stackTrace,
  query: '/(com.mycompany[\.0-9a-z]+)/'
});

Notice the / missing from your query.

Cheers,
Bogdan

from highlight-words.

tricinel avatar tricinel commented on June 22, 2024 1

Ok, cool! I'll polish everything and publish the new version. Thanks for testing and for your suggestion 👍

from highlight-words.

tricinel avatar tricinel commented on June 22, 2024 1

@eriknyk 1.2.0 is published. I'd appreciate a final run through 🙏

from highlight-words.

eriknyk avatar eriknyk commented on June 22, 2024 1

I just can say THANK YO USO MUCH! @tricinel

image

from highlight-words.

tricinel avatar tricinel commented on June 22, 2024

Hey @eriknyk, thanks for getting in touch! Hmm, I haven't considered that use case, so it's not possible at the moment. I'm specifically escaping anything that might look like a regex. I guess it's something we could not do. We could check if the term is a regex and, if it is, let it pass through, otherwise escape as I do now.

I'd like to write some test cases first.

Would you mind sharing a few examples of what you had in mind? Mock code will do just fine.

from highlight-words.

eriknyk avatar eriknyk commented on June 22, 2024

Yeap for sure, Thanks @tricinel

my principal use case is when I want to highlight words with a given pattern like /com.mycompany.com[\.0-9a-z]+/
in this case I want to highlight all strings like

com.mycompany.com.authorization.config

com.mycompany.com.core

com.mycompany.com.controllers.invoices

patterns like that in a very very long text like we have in the android logcat crash reports.

Thanks a lot

from highlight-words.

tricinel avatar tricinel commented on June 22, 2024

@eriknyk something like this.

I published 1.2.0 as a beta. I need to polish it a bit and update the docs, but this should give you an idea and you can tell me if it fits your purpose :)

https://www.npmjs.com/package/highlight-words/v/1.2.0-beta.0

npm install [email protected] or the yarn equivalent should work I think.

You'll see the example for your test case here - and notice that you'll need to use a capture group, i.e. /(com.something.something.else)/ for the split to work properly.

from highlight-words.

eriknyk avatar eriknyk commented on June 22, 2024

Awesome @tricinel,
however, I've update to

"highlight-words": "^1.2.0-beta.0",

but the regex not working.

My code:

stacktraceChunks = highlightWords({
	text: item.stackTrace,
	query: '(com.mycompany[\.0-9a-z]+)'
});

from highlight-words.

eriknyk avatar eriknyk commented on June 22, 2024

It works perfectly!
thank you so much @tricinel

from highlight-words.

tricinel avatar tricinel commented on June 22, 2024

Ah, very nice! Glad it's working! You're very welcome 👍 It was a nice suggestion and I'm sure a useful addition for everyone.

from highlight-words.

Related Issues (10)

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.