Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 15th, 2005, 07:02 AM
Friend of Wrox
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default RegExp looping for multiple strings in string


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

\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
Old June 18th, 2005, 06:00 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

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


Joe (Microsoft MVP - XML)
Old June 20th, 2005, 05:37 AM
Friend of Wrox
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts


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?

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 02:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.