ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   JavaScript........ (https://www.scoobynet.com/computer-and-technology-related-34/232909-javascript.html)

SJ_Skyline 23 July 2003 04:17 PM

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?

Thunder77 23 July 2003 09:25 PM

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

Iain Young 23 July 2003 11:25 PM

You may also want to put it in a loop to replace every occurance of the string, not just the first...

SJ_Skyline 24 July 2003 07:18 AM

cheers guys :)

Dizzy 24 July 2003 08:18 AM

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

here

[Edited by Dizzy - 7/24/2003 8:18:56 AM]

SJ_Skyline 24 July 2003 10:21 AM

Dizzy - WITHOUT using regular expressions

all sorted now WITHOUT re's :)


All times are GMT +1. The time now is 02:56 PM.


© 2024 MH Sub I, LLC dba Internet Brands