0

In my html page I have a lot of strings inside tags. like

<p>Some string 1</p>
<p>Some string 2</p>
<p>Any string 3</p>

I need to put all of them to attribute TRANSLATE, lowercase them and replace all spaces to underscores inside strings.

So I multiselect all of them with holded CTRL, then ctrl+K, ctrl+L make them lowercase, CTRL+x - erase, two left arrows for going inside tags, write translate="PASTE HERE"

Now I have

<p translate="some string 1"></p>
<p translate="some string 2"></p>
<p translate="any string 3"></p>

Next step - I need to make underscores instead of spaces.

To find all translate strings I use regex (?s)translate=".+?" But how to replace? Help.

Sergey Kudryashov
  • 713
  • 2
  • 9
  • 30
  • 1
    Have you tried [this](https://stackoverflow.com/questions/11404156/sublime-text-2-how-do-i-replace-text-in-a-selection)? – CarHa Sep 05 '15 at 12:22

2 Answers2

2

Type ctrl + H and then

Use negative-lookbehind to search spaces which are not preceded by p.

(?<!p)\h+

\h matches only horizontal spaces.

Now replace-all it with _.

Arunesh Singh
  • 3,489
  • 18
  • 26
0

This is simple but will work and faster than looking for a smarter answer.

Find this: translate="(.*) (.*)"

Replace with this: translate="\1_\2"

Keep using Replace All until all your unwanted spaces are underscores (in the example you gave, twice).

jwpfox
  • 5,124
  • 11
  • 45
  • 42