<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY
style="WORD-WRAP: break-word; khtml-nbsp-mode: space; khtml-line-break: after-white-space"
bgColor=#ffffff>
<DIV><FONT face=Arial size=4>Why not just use an array such as</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4>array("[s]mouth.gif[/s]", ":D", "[s]frown.gif[/s]",
":(",) etc then loop through it:</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4> if (word == array[loop_counter]) {word
= array[loop_counter+1]}</FONT></DIV>
<DIV><FONT face=Arial size=4></FONT> </DIV>
<DIV><FONT face=Arial size=4>Tim in Ireland.</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=junado@junado.com href="mailto:junado@junado.com">Julien Nadeau</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=javascript@LaTech.edu
href="mailto:javascript@LaTech.edu">[JavaScript List]</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Saturday, September 24, 2005 5:13
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Javascript] String.replace
and arrays</DIV>
<DIV><BR></DIV>My parsed string does work. It does replace the
[s]mouth.gif[/s] by mouth.gif. What I am trying to do though if to have
[s]mouth.gif[/s] replaced by ":D", [s]tongue.gif[/s] replaced by ":P" and so
on for the 20 or so smileys. So I'm trying to figure out a way to have the
.replace() return the value from an array or something similar, but nothing
has worked so far, and I'm trying to stay away from having to replace them all
by hand.<BR>
<DIV>
<P style="MIN-HEIGHT: 14px; MARGIN: 0px; FONT: 12px Helvetica"><BR></P>
<P style="MARGIN: 0px"><FONT style="FONT: 12px Helvetica" face=Helvetica
size=3>Julien Nadeau</FONT></P>
<P style="MARGIN: 0px"><FONT style="FONT: 12px Helvetica" face=Helvetica
size=3><A
href="mailto:junado@junado.com">junado@junado.com</A></FONT></P></DIV><BR>
<DIV>
<DIV>Le 05-09-23 à 21:31, Troy III Ajnej a écrit :</DIV><BR
class=Apple-interchange-newline>
<BLOCKQUOTE type="cite">
<DIV>
<P><BR><BR></P>
<P><BR>Have you tried to alert your 'parsedString' to see what it
returns,</P>
<P>It is posible that your replace string is escaping the <FONT
color=#cc0033>:</FONT> character ?!<BR><BR></P>
<DIV><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">
<HR color=#a0c6e5 SIZE=1>
From: <I>Julien Nadeau <<A
href="mailto:junado@junado.com">junado@junado.com</A>></I><BR>Reply-To:
<I>"\[JavaScript List\]" <<A
href="mailto:javascript@LaTech.edu">javascript@LaTech.edu</A>></I><BR>To:
<I>"[JavaScript List]" <<A
href="mailto:javascript@LaTech.edu">javascript@LaTech.edu</A>></I><BR>Subject:
<I>[Javascript] String.replace and arrays</I><BR>Date: <I>Fri, 23 Sep 2005
19:14:01 -0400</I><BR><BR>Good evening,</FONT></DIV><FONT
style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #a0c6e5 2px solid; MARGIN-RIGHT: 0px">
<DIV><BR class=khtml-block-placeholder></DIV>I'm rather puzzled by
something I've encountered while playing with the string.replace() regex
function in JavaScript.
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>I have a string that contains text like this:</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>var string = "this is some text [s]mouth.gif[/s] and some more text
[s]tongue.gif[/s]";</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>Where "[s]mouth.gif[/s]" and "[s]tongue.gif[/s]" refers to smiley
images.</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>I'm trying to replace theses with their corresponding ASCII, such as
":D" and ":P".</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>Using string.replace(), I got this regular expression that spot the
[s] tags and parse the content.</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>var parsedString =
string.replace(/\[s\]([a-zA-Z0-9_\.]+)+\[\/s\]/gi, "$1");</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>However, I'm trying to get that $1 value and use it as an array index
where I can store all corresponding ASCII values relative to
filenames.</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>I've tried a few, but yet unsuccesful, solutions.</DIV>
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>Anyone here has an idea on how to make this work?<BR>
<DIV>
<DIV
style="MIN-HEIGHT: 14px; MARGIN: 0px; FONT: 12px Helvetica"><BR></DIV>
<DIV style="MARGIN: 0px"><FONT style="FONT: 12px Helvetica" face=Helvetica
size=3>Julien Nadeau</FONT></DIV>
<DIV style="MARGIN: 0px"><FONT style="FONT: 12px Helvetica" face=Helvetica
size=3><A
href="mailto:junado@junado.com">junado@junado.com</A></FONT></DIV></DIV><BR></DIV><BR>
<P>>_______________________________________________<BR>>Javascript
mailing list<BR>><A
href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</A><BR>><A
href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</A><BR></P>
<DIV><BR class=khtml-block-placeholder></DIV></BLOCKQUOTE></FONT></DIV><FONT
style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif"><BR clear=all>
<HR>
Express yourself instantly with MSN Messenger! <A
href="http://g.msn.com/8HMAEN/2740??PS=47575" target=_top>MSN Messenger</A>
Download today it's FREE! </FONT>
<DIV
style="MARGIN: 0px">_______________________________________________</DIV>
<DIV style="MARGIN: 0px">Javascript mailing list</DIV>
<DIV style="MARGIN: 0px"><A
href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</A></DIV>
<DIV style="MARGIN: 0px"><A
href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</A></DIV><BR
class=Apple-interchange-newline></BLOCKQUOTE></DIV><BR>
<P>
<HR>
<P></P>_______________________________________________<BR>Javascript mailing
list<BR>Javascript@LaTech.edu<BR>https://lists.LaTech.edu/mailman/listinfo/javascript<BR></BLOCKQUOTE></BODY></HTML>