1

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.

1 Answer 1

7

You can use String.replace() function like this:

var modifiedString = kurzerText.replace("'+relation+'", newValue);

String.replace() on MDN

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.