Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use wildcard in replace string?

I need to change all:

<label for="*">

into

<label for="*" class="inline checkbox">

But it turns out all my <label for="XXXXXX"> were turned into <label for="*" class="inline checkbox">. Yes, the * is literally kept as a string not as a wildcard.

How come the wildcard is only effective in Find not in Replace? What should I input in the Replace string?

like image 604
Blaise Avatar asked Sep 19 '12 13:09

Blaise


1 Answers

I'm not sure if there is a way to do this with wildcards, but you can get it done using regular expressions:

  1. In the Find and Replace dialog box, below Find Options, check Use: and from the dropdown select Regular expressions.
  2. In the text box for Find What, type: \<label for="{.*}"\>
  3. In the text box for Replace with, type: <label for="\1" class="inline checkbox">

Notes:

  • I escaped < and > with \ because they are special characters.
  • .* will match any string.
  • In the replace text, \1 will replace with the string found between the {} in the find expression.

Also, if you click the arrows next to the find and replace text boxes, you will find more info about the special characters.

like image 53
Forte L. Avatar answered Sep 19 '22 18:09

Forte L.