Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 15th, 2005, 07:02 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default RegExp looping for multiple strings in string

Hi,

I am trying to find a way of using the RegExp constructor in order to look for various strings within one string and then replace them with html strings, so I can pass the newly constructed string into an innerHTML routine. The strings are ":\)", ":\(", ":D" and ":s". Anyone any clue how to do this? Would it be a loop? Each string needs a different HTML string.

Help much appreciated
interrupt

__________________
\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
  #2 (permalink)  
Old June 18th, 2005, 06:00 AM
joefawcett's Avatar
Wrox Author
Points: 9,716, Level: 42
Points: 9,716, Level: 42 Points: 9,716, Level: 42 Points: 9,716, Level: 42
Activity: 8%
Activity: 8% Activity: 8% Activity: 8%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,067
Thanks: 1
Thanked 37 Times in 36 Posts
Default

I'm not sure I fully understand but with a regular expression you can use the pipe symbol as "or":
Code:
/(a|b)/
matches "a" or "b".

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old June 20th, 2005, 05:37 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok,

I have a textarea in which a user will type various things. Take the following string:

I am posting a smile :). I am posting a grin :D. I am posting a sad face :(.

Where each of the smilie symbols appear I want to replace them with individual html strings. If its a ":)" then I replce it with <img src =\"smile.gif\">, or if its a ":D", then I replace it with <img src =\"grin.gif\">. I have no problem with the replace method, but I am trying to figure out what to do when there are multiple different smilies. Would I need to have multiple functions looking at the same textarea?
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple String Replace berna_isct XSLT 5 May 20th, 2008 02:47 AM
looping thru string havey C# 1 April 26th, 2008 05:13 PM
Looping within a string stolte XSLT 6 May 18th, 2007 04:19 PM
Replace multiple instances of a String interrupt Javascript How-To 2 June 14th, 2005 06:48 AM
Multiple DSN's using connection strings hcweb Classic ASP Basics 1 February 23rd, 2004 01:42 AM



All times are GMT -4. The time now is 10:15 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.