Reputation: 306
I have an JSON-file which looks like this:
[
{
"typ":"alle",
"id":1,
"detailMode":"heute",
"bedingung":[
"evk_gebaeude",
"evk_durchschnitt"
],
"kurzerText":"Energieverbrauchskennwert '+relation+' TU Durchschnitt",
"relation_Positiv":"liegt niedriger als der",
"relation_Neutral":"liegt niedriger im",
"relation_Negativ":"liegt höher als der"
}
]
Now I want use the text in "kurzerText" and replace '+relation+' with relation_Positiv, relation_Neutral or relation_Negativ.
I could probably do that with regular Expressions, but I wondered if there is a easier solution? I'm using javascript and jQuery.
Upvotes: 1
Views: 1918
Reputation: 5008
You can use String.replace()
function like this:
var modifiedString = kurzerText.replace("'+relation+'", newValue);
Upvotes: 7