I have the following text in a textarea:
<textarea class="content">
[shortcode1 param1=test param2=john]
[shortcode2 param1=test param2=john]
[shortcode1 param1=john param2=exchange]
</textarea>
How I want to change the parameter names, but only if its shortcode1
So this should be the result:
<textarea class="content">
[shortcode1 newparam1=test newparam2=john]
[shortcode2 param1=test param2=john]
[shortcode1 newparam1=john newparam2=exchange]
</textarea>
I currently use jQuery the following way:
$(".content").text($(".content").text().replace("param1", "newparam1"));
$(".content").text($(".content").text().replace("param2", "newparam2"));
But as you can see, it takes not only the params of shortcode1, but all.
Can somebody help me? And is there a way to optimize the jquery part, because I have 10 of this replacements and may I can combine them?