| | |
trim a string help
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
i have a string like this:
how can i take off that hash sine?
regards
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
location = '#http://www.website.com';
how can i take off that hash sine?
regards
no dejes para mañana lo que puedes hacer hoy
You can use the
e.g.
replace() method.e.g.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
loc = "#http://www.wesite.com/".replace(/#/ig, ""); alert( loc );
•
•
•
•
You can use thereplace()method.
e.g.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
loc = "#http://www.wesite.com/".replace(/#/ig, ""); alert( loc );
#http://www.website.com/test.html#Contacts . JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
loc = "#http://www.wesite.com/".replace(/^#*/i, ""); alert(loc);
Last edited by itsjareds; May 25th, 2009 at 3:30 am.
Mark your post as Solved if you've been helped!
I learn by helping others learn.
If you find one of my posts helpful, don't be afraid to give me a reputation bump :D
I learn by helping others learn.
If you find one of my posts helpful, don't be afraid to give me a reputation bump :D
No it's not that bad.
If you will apply proper techniques and good workaround in your script, im sure everything can be organized.
Here's a short example, so that you can see the big difference between the codes.
If you will apply proper techniques and good workaround in your script, im sure everything can be organized.
Here's a short example, so that you can see the big difference between the codes.
javascript Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <title>CROSS-PLATFORM</title> <script type="text/javascript"> // <![CDATA[ var include, url; include = function( url ) { loc = "#http://www.web#site.#com/#contact".replace(/^#*/i, ""); alert( loc ); // Check the first pattern and observed the output w/o g-flag. delete loc; loc = "#http://www.web#site.#com/".replace(/#/ig, ""); // With g-flag's! alert( loc + url ) // Now we will use it with a global flag and by adding up some arguments' we can organized everything and also remove unnecessary characters in the url. } window.onload = include( "#contact" ); // ]]> </script> </head> <body> </body> </html>
I suppose it depends on what your circumstances are. I assumed that he was using AJAX and had a link like what he proposed. If he just needed to remove the first #, he could also have done:
JavaScript Syntax (Toggle Plain Text)
var string = "#http://www.example.com"; var newString = string.substr(1);
Mark your post as Solved if you've been helped!
I learn by helping others learn.
If you find one of my posts helpful, don't be afraid to give me a reputation bump :D
I learn by helping others learn.
If you find one of my posts helpful, don't be afraid to give me a reputation bump :D
![]() |
Similar Threads
- Trim function (C++)
- search key highlighting ? (PHP)
- Sending a string/byte to the usb port (C#)
- Reading .dat file data into an array (C#)
- put sting into an array (C++)
- Trim Strings (JavaScript / DHTML / AJAX)
- Convert a string (diffrent formats) to date (C#)
- i need help (Java)
- Multi-threading with C++.NET (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How to display the details in right frame?
- Next Thread: Javascript/flash onClick Issues
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array beta box browser captchaformproblem cart child close codes column css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 onerror onmouseoutdivproblem onmouseover onreadystatechange paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating synchronous toggle unicode variables w3c web webservice window windowofwords xml \n





