SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: string inside another string
-
Aug 28, 2006, 11:27 #1
- Join Date
- Nov 2005
- Posts
- 24
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
string inside another string
Could anyone please tell me how to place a string inside of another string.
For example, say I have the string www.url.com/url/ on my web page but I want the string to have a space added to it right before the url/ when the page loads, so that it now appears www.url.com/ url/
Any help would be great.
P.S. Don't worry about the onload stuff I just need to know how to concat a string inside of another string.
-
Aug 29, 2006, 04:40 #2
- Join Date
- Oct 2004
- Location
- Troy, Mi
- Posts
- 231
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Personally, I would use the substring and indexOf functionality in javascript to find the first instance of the single / in the url; then divide it into two strings:
www.url.com/
url/
then concat the strings with a space
www.url.com/ + " " + url
http://www.w3schools.com/jsref/jsref_substr.asp
-
Aug 29, 2006, 05:08 #3
- Join Date
- Jun 2006
- Location
- Iran, Tehran
- Posts
- 475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
substring
As jtrelfa mentioned, The attribute substring(STRING,int a,int b) does the trick. something like,
Code:substring(YOUR_STRING,1,THE_PLACE_YOU_MAY_BREAK)
-
Aug 29, 2006, 05:11 #4
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
borna, java is not the same thing as javascript
please don't confuse the two!
-
Aug 29, 2006, 05:13 #5
- Join Date
- Jun 2006
- Location
- Iran, Tehran
- Posts
- 475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
here, fortunately, the same ideas work. Thanks for your smart point.
Bookmarks