I have a lot of files where i have something similar
<span translate>textTo.translate</span>
What need to look like is
<span>{{ $t("textTo.translate") }}</span>
What i do now is find all occurrences of span translate>
and replace all
with span>{{ $t("
and then go thru file and finish step by step
Is there any regex that i could use in replace all to achieve this?
What i managed to do is to select all (span translate>)[^<>]+(?=<)
but i cannot find replacement regex
2
Answers
nvm, found answer
but for some reason works only in VSCode while fails in PHPStorm.Find regex:
span translate>([^<>]+(?=))<
Replace regex:
span>{{ $t("$1") }}<
You can use
Find:
<spans+translate>([^<>]+)<
Replace:
<span>{{ $t("$1") }}<
See the regex demo.
Details:
<spans+translate>
– a<span
string, one or more whitespaces and then atranslate>
string([^<>]+)
– Group 1 ($1
refers to this group value): one or more chars other than<
and>
<
– a<
charThe replacement is
<span>{{ $t("
+ Group 1 value +") }}<
text.See the demo: