tones Posted August 25, 2006 Share Posted August 25, 2006 Is it possible, and if so, how would I replace a right bracket string ')' using .replace(/)/ 'foo') doesn't work of course as the bracket confuses the whole thingMany thanks in advance, tones Link to comment Share on other sites More sharing options...
Golanlan Posted August 26, 2006 Share Posted August 26, 2006 Can be found easly on w3schools tutorials.. <script type="text/javascript">var str="meow *code*"document.write(str.replace(/*code*/,"foo"))</script> replace *code* with the code for "right parenthesis" on HTML ASCII Reference Link to comment Share on other sites More sharing options...
tones Posted August 26, 2006 Author Share Posted August 26, 2006 Can be found easly on w3schools tutorials..<script type="text/javascript">var str="meow *code*"document.write(str.replace(/*code*/,"foo"))</script> replace *code* with the code for "right parenthesis" on HTML ASCII Reference Thank you golanlan, the HTML ASCII ref was the bit I was after. Link to comment Share on other sites More sharing options...
Golanlan Posted August 26, 2006 Share Posted August 26, 2006 Thank you golanlan, the HTML ASCII ref was the bit I was after.Sure, glad I could help. Link to comment Share on other sites More sharing options...
tones Posted August 26, 2006 Author Share Posted August 26, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now