Evaluating a string of text and looking for specific characters

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Evaluating a string of text and looking for specific characters

biffjo
Hi,

I am using freemarker to evaluate a string of text from a twitter xml feed.

At this point, I have the text in a string. Let's say its this for example:

hello @funkhauser, I am going to see the #phillies this year.

What I need to do is 'loop' through the string and when it hits on an '@' or '#' symbol, I need to make that part of the string a link. Anyone have a suggestion on the best way to do this?

Thanks in advance,
B
Reply | Threaded
Open this post in threaded view
|

Re: Evaluating a string of text and looking for specific characters

Guo Du
On Mon, Dec 21, 2009 at 2:08 AM, biffjo <[hidden email]> wrote:
>
> hello @funkhauser, I am going to see the #phillies this year.
>
> What I need to do is 'loop' through the string and when it hits on an '@' or
> '#' symbol, I need to make that part of the string a link. Anyone have a
> suggestion on the best way to do this?
Even it's possible using  string buildin split function (
http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_split)
to search the @# and generate links, but I would suggest you write a
custom directive
(http://freemarker.org/docs/dgui_misc_userdefdir.html) to search the
special chars and generate links. You could using regex to search
chars and do the trick, it's much easier :) e.g.
<@twitter>
hello @funkhauser, I am going to see the #phillies this year.
</@twitter>

-Guo

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user