Jump to content

how to .replace a right bracket??


tones

Recommended Posts

Doesn't seem to work, namely that the string contains ")" not the code for it. I have no control over the original string, hence trying to edit it using replace. I have been using the w3c schools replace demo and trying many things, and I cannot seem to replace the right bracket

<script type="text/javascript">var str=")"document.write(str.replace(/)/,"W3Schools"))</script>

EDIT: Have solved it, fyi:

<script type="text/javascript">var str="(W3Schools)";var bracket=")";document.write(str.replace(bracket," Rocks!"))</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...