Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

JavaScript........

Old 23 July 2003, 04:17 PM
  #1  
SJ_Skyline
Scooby Senior
Thread Starter
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Question

ok, my brain is bleeding....

Is there a way in JavaScript to replace a segment of a string WITHOUT using regular expressions?

I have a hidden form item which contains a string of numbers with delimiters:
e.g. ,2,234,24,87,89,290,

I am passing a function a number I want to remove from the string:
e.g. 234

Without using a regular expression, I want the string to become:
,2,24,87,89,290,


any ideas?
Old 23 July 2003, 09:25 PM
  #2  
Thunder77
Scooby Regular
 
Thunder77's Avatar
 
Join Date: Jul 2002
Location: Northants Gamertag: ThunderXUK
Posts: 554
Likes: 0
Received 0 Likes on 0 Posts
Post

you could use String.indexOf to get the position and then take apart the string left of the index and add the remainder back on?!

http://developer.netscape.com/docs/m...ng.htm#1196895
Old 23 July 2003, 11:25 PM
  #3  
Iain Young
Scooby Regular
 
Iain Young's Avatar
 
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes on 0 Posts
Post

You may also want to put it in a loop to replace every occurance of the string, not just the first...
Old 24 July 2003, 07:18 AM
  #4  
SJ_Skyline
Scooby Senior
Thread Starter
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Smile

cheers guys
Old 24 July 2003, 08:18 AM
  #5  
Dizzy
Scooby Regular
 
Dizzy's Avatar
 
Join Date: May 2001
Posts: 2,537
Likes: 0
Received 0 Likes on 0 Posts
Post

er.. Replace(",234,",",")

here

[Edited by Dizzy - 7/24/2003 8:18:56 AM]
Old 24 July 2003, 10:21 AM
  #6  
SJ_Skyline
Scooby Senior
Thread Starter
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Smile

Dizzy - WITHOUT using regular expressions

all sorted now WITHOUT re's


Thread Tools
Search this Thread

All times are GMT +1. The time now is 12:01 AM.