Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to highlight with regex #9

Open
batty211 opened this issue Jan 24, 2021 · 1 comment
Open

how to highlight with regex #9

batty211 opened this issue Jan 24, 2021 · 1 comment

Comments

@batty211
Copy link

can you explain how to highlight with regular expression.

@mcshaz
Copy link

mcshaz commented Jun 23, 2023

I was exploring this library and saw this question. Untested, but I would assume that if you wanted to highlight all digits /\d/ for example, you would put:

(...
computed: {
  segments() {
    return [...this.text.matchAll(/\d+/g)].map(m => ({
      start: m.index,
      end: m.index + m[0].length,
      tag: { class: "blue" }
    }))
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants