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........

Thread Tools
 
Search this Thread
 
Old Jul 23, 2003 | 04:17 PM
  #1  
SJ_Skyline's Avatar
SJ_Skyline
Thread Starter
Scooby Senior
 
Joined: Apr 2002
Posts: 21,922
Likes: 2
From: Limbo
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?
Reply
Old Jul 23, 2003 | 09:25 PM
  #2  
Thunder77's Avatar
Thunder77
Scooby Regular
 
Joined: Jul 2002
Posts: 554
Likes: 0
From: Northants Gamertag: ThunderXUK
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
Reply
Old Jul 23, 2003 | 11:25 PM
  #3  
Iain Young's Avatar
Iain Young
Scooby Regular
 
Joined: Sep 1999
Posts: 6,956
Likes: 0
From: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Post

You may also want to put it in a loop to replace every occurance of the string, not just the first...
Reply
Old Jul 24, 2003 | 07:18 AM
  #4  
SJ_Skyline's Avatar
SJ_Skyline
Thread Starter
Scooby Senior
 
Joined: Apr 2002
Posts: 21,922
Likes: 2
From: Limbo
Smile

cheers guys
Reply
Old Jul 24, 2003 | 08:18 AM
  #5  
Dizzy's Avatar
Dizzy
Scooby Regular
 
Joined: May 2001
Posts: 2,537
Likes: 0
Post

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

here

[Edited by Dizzy - 7/24/2003 8:18:56 AM]
Reply
Old Jul 24, 2003 | 10:21 AM
  #6  
SJ_Skyline's Avatar
SJ_Skyline
Thread Starter
Scooby Senior
 
Joined: Apr 2002
Posts: 21,922
Likes: 2
From: Limbo
Smile

Dizzy - WITHOUT using regular expressions

all sorted now WITHOUT re's
Reply




All times are GMT +1. The time now is 10:42 AM.