How would a regular expression find a html + attribute value?

2

I want to give a find / replace on all the html "data-placeholder" attributes and their values, from my application, through the Visual Studio search.

For this I need to put together a regular expression and put it straight into the Visual Studio find, activating the regular expressions option.

But I know almost nothing about regular expressions in order to create one of the type.

I would like the regular expression to make me find all these string types:

data-placeholder="Texto 1"
data-placeholder="Texto 2"
data-placeholder="Texto com muitos caracteres"
data-placeholder=""
    
asked by anonymous 22.01.2016 / 18:49

2 answers

5

I'm not really wild in regex rs, but I'll try to help:

(data-placeholder=")(\w+(\s+|\w+)\w+)"
    
22.01.2016 / 19:29
1

You can do it like this:

data-placeholder="([a-zA-Z0-9 ]*)"

If _ is not a problem it decreases it to:

data-placeholder="([\w ]*)"

Explanation

  • data-placeholder=" literal search, must contain string.
  • (...) Generates a group, match [1], because match [0] is the string itself.
  • [a-zA-Z0-9 ] or [\w ] sequence of valid characters, regardless of order.
  • % with% quantified, from zero to infinity, always capturing the maximum.
  • * literal search, must contain string.
  • Obs

    "

        
    25.01.2016 / 11:12