Re: Emoticon text parser
- From: Karsten Wutzke <kwutzke@xxxxxx>
- Date: Thu, 20 Mar 2008 12:56:17 -0700 (PDT)
On 20 Mrz., 19:01, "Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx>
wrote:
On Thu, 20 Mar 2008 10:40:39 -0700, Karsten Wutzke <kwut...@xxxxxx> wrote:
how do I write a text parser that will detect many ":-)", "]:->"
strings so that they can be replaced with small icons a text
component?
That all depends on how you're formatting the text to include the icons.
But, for example, if you're using HTML in one of the Swing controls that
can display HTML, you might just use the java.util.regex package useful.
Just use it to do a straight search-and-replace of emoticon strings with
the appropriate HTML "img" tag.
Other than that, your question is pretty broadly worded. You're either
going to get a lot of replies that aren't applicable, or none at all due
to the vagueness of the problem description.
Pete
The strings to be parsed are (at first) plain strings without any
control codes or any programming language constructs... but they
contain completely differing smiley/emoticon code, where some codes
might contain other, so I have to figure that out:
Example:
one might express *very sad* or *weeping* by writing the string ":-(("
this smiley code however starts with ":-(", the smiley code for *sad*
or *unhappy*...
OK solution here would be to sort the order of smileys tested against
by their code string length, here first check ":-((", then ":-("...
But I need some general parsing approach. Regex really necessary?
Pattern? Looks very complicated to me... I doubt I can use a pattern
for codes that range from ":-)" over "}:->" over ";)" to (CIG)...
Karsten
.
- Follow-Ups:
- Re: Emoticon text parser
- From: Peter Duniho
- Re: Emoticon text parser
- References:
- Emoticon text parser
- From: Karsten Wutzke
- Re: Emoticon text parser
- From: Peter Duniho
- Emoticon text parser
- Prev by Date: Re: JScrollPane
- Next by Date: Re: Convert float to string
- Previous by thread: Re: Emoticon text parser
- Next by thread: Re: Emoticon text parser
- Index(es):
Relevant Pages
|