GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Chat filtering Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Chat filtering" Watch "Chat filtering" New topic
Author

Chat filtering

ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
I am writing a method that can do some filtering and manipulations on a String intended for chat client.

The method main purpose is to recognize commands and returns the appropriate output and do some string replacements.

Here what I have come up with so far:

This seems to work a bit but it has limitations and performance hit in String replace methods.

I want to do it using better and efficient approach, I have looked at Pattern and Matcher replacement methods but don't seems to figure it out with this context.

Further I would like to pass for example: "/me grins" and get "Ahmed grins"

Any ideas would be appreciated.
Thanks in advance.
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
Originally posted by Ahmed Yehia:
I want to do it using better and efficient approach, I have looked at Pattern and Matcher replacement methods but don't seems to figure it out with this context.

Further I would like to pass for example: "/me grins" and get "Ahmed grins"


You're on the right track.
Read the docs over again and give it a try - you should be able to reimplement what you have with them. Once you have that it should scale better.

java.util.regex.Pattern
java.util.regex.Matcher
java.util.Scanner

I found myself recently using

java.lang.String.replaceAll() - which is shorthand for the above.



Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
This one seems more logical:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Chat filtering