1

I'm using VSCode for html editing. In VSCode it's very easy to select same occurences of a piece of code. What i need is selecting all ocuurances of an html attribute (like class, aria-label, etc.) with different values. Here's an example:

I want to select all "aria-label" occurences with the values included. So these will be selected:

aria-label="Apple"
aria-label="Oranges"
aria-label="Multiple Fruit Names"
aria-label=""
...

Is there a way to do that in VSCode?

2 Answers 2

1

You could use a regex for that:

^aria-label="[^"]*"

Explanation:

  • '^' ... matches newline
  • 'aria-label=' ... that's your "search word"
  • '[^"]' ... any character
  • '*' ... zero or more occurrences of stuff within the group

Don't forget to enable regex search in search dialog (see below):

enter image description here

This is a good starting point to grasp the regex magic: https://en.wikipedia.org/wiki/Regular_expression#Basic_concepts .

Sign up to request clarification or add additional context in comments.

6 Comments

better to use ^aria-label="[^"]*"
rioV8 thank you, updated answer with your suggestion
Thanks for reply but somehow it doesn't work. I activated regex in vscode searchbox. It doesn't match any results. Here is a pen, and it says no match too: regex101.com/r/npLpaI/1
Okay, on your link there is no: "aria-label=" in the text, only "aria-....". What would you like to match?
If i could select everything beginning with "aria-" (and including the rest of the attribute and the value the value that belongs to it) it could be wonderful.
|
1

I understood that regex knowledge essential so for last couple of days i studied Regex101, this is what worked for me on this question.

aria-[a-zA-Z]*="[A-Za-z\s]*"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.