hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Javascript variable manipulation.. should be easy
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Javascript variable manipulation.. should be easy

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-07-2005, 05:49 PM
ilyash ilyash is offline
Web Hosting Master
 
Join Date: Dec 2002
Location: NY, NY
Posts: 3,975

Javascript variable manipulation.. should be easy


Basically I have

var text = "ABCD";


Now i have to look for single quotes ' andamperes &

I am not too familiar with javascript..

I work mainly with JAVA so I am guessing you would need a loop..

for(int i=0; i<var.trim().length;i++){
if(text.indexOf(" ' ") > -1){
int pt = text.indexOf(" ' ");
text = text.substring(0,pt) + "WHAT TO REPLACE SING QUOTE WITH" + text.substring(pt+1,text.length);
//repeat for all the things i want to replace
}


Now how would i do this in javascript?

}

Reply With Quote


Sponsored Links
  #2  
Old 07-08-2005, 08:04 AM
gogocode gogocode is offline
Web Hosting Evangelist
 
Join Date: Mar 2004
Location: New Zealand
Posts: 527
Why not just use a regular expression?

pt = pt.replace(/'/g, 'whatever').replace(/&/g, 'whatever2');

__________________
James Sleeman
PHP Programmer | Specialist PHP 5 Web Hosting

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Strategies to Reduce Operating Costs, Avoid Email Blacklisting and Improve Deliverability Webinars 2013-05-15 11:27:46
Facebook's Recently Acquired Mobile App Platform Parse Launches Web Hosting for Developers Web Hosting News 2013-05-08 10:49:17
WHD.india 2013 Web Hosting Events 2013-04-24 18:18:58
The Variable Requirements of Data Center Vendor Selection: Andrew Schaap of Digital Realty Trust Web Hosting News 2011-09-27 15:06:29
Colocation Firm Mac Mini Vault Uses Apple TV as Web Server in 24-Hour Experiment Web Hosting News 2011-05-20 19:57:22


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?