/    Sign up×
Community /Pin to ProfileBookmark

So simple… so why can’t I find the solution.

I have a javascript that produces a preview window of a user-submitted form for users to view how their submission will look when finalized. Only problem is that at times {tokens} are used in place of ‘real’ html tags. How can I get my script to scan through and replace all instances of (example: {tag} and {/tag}) with (example: <tag> and </tag>). This seems so simple when I type it out like this… why can’t I get the bloody thing to work?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMar 04.2006 — str = str.replace(/{/g, "<").replace(/}/g, ">");
Copy linkTweet thisAlerts:
@manikinxvxauthorMar 06.2006 — Unfortunately this solution corrupted the script and the preview window wouldn't pop up. This is the same problem I had with everything else I've tried.

Then portion of the script responsible for writing this line is being generated by PHP, possibly resulting in a syntax-related failure, but nothing looks askew in the source code.
Copy linkTweet thisAlerts:
@phpnoviceMar 06.2006 — Well, you said you wanted all instances replaced -- and that is what you got. If it "corrupted" anything, then you didn't really want all instances replaced.
×

Success!

Help @manikinxvx spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...