how would i check through a submitted string and replace all traces of smilies with the respective <img />'s please?
You could use a map:
[url]http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.html[/url]
You need to iterate through the key set and do a replace all with its matching string value.
Regular expressions are another (probably easier) option.
might you be able to explain that further or provide an example of how ot use that please?
[editline]08:55PM[/editline]
sorry, im not that skilled at java, still learning :$
In AS* it'd just be
for(var i in smileycodes){
text.split(smileycodes[i]).join(smileys[i]);
}
Dunno if there are similar functions in Java.
I have a IM I wrote for school that uses PHP to replace :) with an image tag, if its usefull, I will give you a copy of the code.
I think he is asking for a Java code sample, not PHP.
[QUOTE=geel9;24142192]In AS* it'd just be
for(var i in smileycodes){
text.split(smileycodes[i]).join(smileys[i]);
}
Dunno if there are similar functions in Java.[/QUOTE]
Who gives a flying fuck about how it is done in AS. He wants java.
[editline]04:58PM[/editline]
[QUOTE=TommieBoy;24145606]I think he is asking for a Java code sample, not PHP.[/QUOTE]
If you are referring to geel9, thats Action Script.
[QUOTE=i300;24147064]Who gives a flying fuck about how it is done in AS. He wants java.
[editline]04:58PM[/editline]
If you are referring to geel9, thats Action Script.[/QUOTE]
I was suggesting a method of doing it if there happen to be similar functions in Java.
string.replace
ok, well i was preferring Java, but any will work really, just must preferably be a desktop app
[QUOTE=CountNoobula;24158418]ok, well i was preferring Java, but any will work really, just must preferably be a desktop app[/QUOTE]
for(int i in smilycodes){
userMessage.replace(smileycodes[i],smileyHTML[i]);
}
[editline]04:34PM[/editline]
smileycodes and smileyHTML are arrays. Smileycodes being an array of the user codes(":)") etc. and smileyHTML being an array of the img code.
[QUOTE=i300;24147064]Who gives a flying fuck about how it is done in AS. He wants java.
[editline]04:58PM[/editline]
If you are referring to geel9, thats Action Script.[/QUOTE]
I was talking to Chris. I know what PHP is.
Sorry, you need to Log In to post a reply to this thread.