Selecting all same html attributes with (different) values included in VSCode

Viewed 202

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

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]*"

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 .

Related