Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 6th, 2008, 12:05 PM
gilgalbiblewhee gilgalbiblewhee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 355 gilgalbiblewhee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 3 m 31 sec
Number of bans: 1
Reputation Power: 0
Javascript regex for eliminating punctuations array

I made an array of punctuation which I want to eliminate from the string:
Code:
		/*to eliminate the punctuations*/
		var punctuations = new Array();
		punctuations[0] = ":";
		punctuations[1] = ";";
		punctuations[2] = ",";
		punctuations[3] = ".";
		punctuations[4] = "?";
		punctuations[5] = "(";
		punctuations[6] = ")";
		var myOldString = searchChapWords[i].innerHTML;
		for(punct=0; punct<punctuations.length; punct++){
			var myNewString = myOldString.replace(/"punctuations[punct]"/g, punctuations);
		}
		document.write("Old string =  " + myOldString); 
		document.write("<br />New string = " + myNewString);
		/*end*/

What's the correct way of doing it?
__________________
Gilgal's website:
Wheel Of God
Now easy to post scripture verses!
Portfolio

Last edited by gilgalbiblewhee : November 6th, 2008 at 12:33 PM.

Reply With Quote
  #2  
Old November 9th, 2008, 02:14 PM
prometheuzz prometheuzz is offline
User 165270
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 497 prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 5 Days 10 h 14 m 35 sec
Reputation Power: 936
Why sore them in an array? Why not do something like this:
Code:
var myNewString = myOldString.replace(/[:;,.?()]/g, "");

?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Javascript regex for eliminating punctuations array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap