string.replace on multiple words within a block of text ???

gcomm

Client
Регистрация
01.03.2011
Сообщения
332
Благодарностей
93
Баллы
28
string.replace on multiple words within a block of text ???


My text file is layed out like so...

##keyword1## is the best product ever made. ##keyword2## is the best product never eaten.



The macro to replace keyword1 looks like so....

{-String.Replace-|-{-FieldData.FieldData-|-●5●7●8●0●9●1●-|-≡1≡8≡3≡3≡4≡9≡3≡6≡6≡1≡-}-|- ##keyword1##-|-{-FieldData.FieldData-|-●5●7●8●0●9●1●-|-≡4≡6≡8≡3≡9≡1≡6≡6≡7≡935436431-}-}

can I put more than one replacement within one macro to process the entire block in one (or a few) step ??



for example:


{-String.Replace-|-{-FieldData.FieldData-|-●5●7●8●0●9●1●-|-≡1≡8≡3≡3≡4≡9≡3≡6≡6≡1≡-}-|- ##keyword1##-|-{-FieldData.FieldData-|-●5●7●8●0●9●1●-|-≡4≡6≡8≡3≡9≡1≡6≡6≡7≡935436431-}-{-FieldData.FieldData-|-●5●7●8●0●9●1●-|-≡1≡8≡3≡3≡4≡9≡3≡6≡6≡8≡-}-|- ##keyword2##-|-{-FieldData.FieldData-|-●5●7●8●0●9●1●-|-≡4≡6≡8≡3≡9≡1≡6≡6≡7≡935436438-}-}
 

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
You should use javascript as macro.

{-JS.Execute-|-
var str="keyword1 is the best product ever made. keyword2 is the best product never eaten";
var str2 = str.replace("keyword1", "product1");
str2.replace("keyword2", "product2");
-}
 
  • Спасибо
Реакции: gcomm

gcomm

Client
Регистрация
01.03.2011
Сообщения
332
Благодарностей
93
Баллы
28
Looks good, I am interested to see if an execution result can be entered as the var for "product1" / "product2" etc.

I will test it -

edit:
WITH EXECUTION RESULTS I AM GETTING NO DATA AFTER JS RUNS... I also ran a prep.js - no go ! hmmmm ?

{-JS.Execute-|-var str="{-FieldData.FieldData-|-●6●6●4●2●2●9●-|-≡6≡7≡5≡1≡9≡4≡2≡1≡7≡-}";
var str2 = str.replace("##IMG##", "{-FieldData.FieldData-|-●6●6●4●2●2●9●-|-≡1≡9≡4≡2≡8≡2≡1≡0≡2≡9≡-}");-}
 

Stereomike

Client
Регистрация
29.03.2011
Сообщения
221
Благодарностей
30
Баллы
0
I use a several macros to achieve this. One feeds into the next. This shouldn't be a showstopper, it just amkes your template a bit bigger. it works even if one of the steps has nothing to replace, so it won't break if you don't use every variable in everey text.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)