The Artima Developer Community
Sponsored Link

Java Answers Forum
need help regex ...Word Possibility ?

15 replies on 2 pages. Most recent reply: Oct 2, 2005 10:38 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 15 replies on 2 pages [ 1 2 | » ]
Putu Ardi

Posts: 2
Nickname: putuniki
Registered: Sep, 2005

need help regex ...Word Possibility ? Posted: Sep 20, 2005 6:23 PM
Reply to this message Reply
Advertisement
Dear friend's

Word Possibility,
Would you like to help me. I have a problem with regex.
How can i match the word :
The input is bank word and character, then will find from that character how word find in bank word input. Please post me the code in java.

Example :

Input bank words
ant
bee
cat
dog
ewe
fly
gnu

Input character:
b e w
b b e e w w
t a n c u g d

Output:
0
2
3

Input charackter check with input bank word if match then show output (how much match), if not output 0. Thank for your help.

Regards,
Putu


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: need help regex ...Word Possibility ? Posted: Sep 20, 2005 10:37 PM
Reply to this message Reply
Are the bottom ones (input character) past in as a character
array. Clarify and we'll go from there - that is if I find
the time - its a fairly simple algorithm though.

If you respond and find that we are too long to respond
just Google "Java String Matching Tutorial" that should
probably do the trick.

Spike

Putu Ardi

Posts: 2
Nickname: putuniki
Registered: Sep, 2005

Re: need help regex ...Word Possibility ? Posted: Sep 23, 2005 8:27 AM
Reply to this message Reply
Would you like send me the code. Thank.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: need help regex ...Word Possibility ? Posted: Sep 25, 2005 10:08 PM
Reply to this message Reply
> Would you like send me the code. Thank.

Yo answer the question first? Its not clear
as to how the characters are past in for comparison.
Clarify that and I will send you *pseudo-code*
not code - depending on the mood, I'm usually not
in the business of Spoon feeding.

Iwan Setyawan Herwanto

Posts: 4
Nickname: rainstorm
Registered: Sep, 2005

Re: need help regex ...Word Possibility ? Posted: Sep 28, 2005 6:56 AM
Reply to this message Reply
Can you send that pseudo code to me? (word possibility)
Because its important to me.... please....
if you can, more fast more good..
you can send that code to iwan_gita@yahoo.com

regard,
Iwan

Iwan Setyawan Herwanto

Posts: 4
Nickname: rainstorm
Registered: Sep, 2005

Re: need help regex ...Word Possibility ? Posted: Sep 28, 2005 6:57 AM
Reply to this message Reply
Can you send that pseudo code for me too??
i need it.....
thanks you very much, putu ardi..


regard,
Iwan

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: need help regex ...Word Possibility ? Posted: Sep 28, 2005 7:01 AM
Reply to this message Reply
There is a serious communication breakdown here.
Either that or y'all have some serious issues!!

Iwan Setyawan Herwanto

Posts: 4
Nickname: rainstorm
Registered: Sep, 2005

Re: need help regex ...Word Possibility ? Posted: Sep 28, 2005 7:07 AM
Reply to this message Reply
Kondwani...
Can you send that pseudo code (word possibility) for me now...
Because i need it for tommorow morning...
You can send it to iwan_gita@yahoo.com
Thank you very much...



Best regard,
Iwan Setyawan Herwanto

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: need help regex ...Word Possibility ? Posted: Sep 28, 2005 7:51 AM
Reply to this message Reply
I haven't tried to compile this yet but try to compile
and run it, hopefully there are no typos - which may
lead to syntax errors. But it should do the job for you.
import java.io.*;
class I_M_N_S_WIPE{
   public boolean computeInterchangeable(String idiot, String knitwit){
      if(idiot.toUpper().contains(new StringBuffer("IWAN"))||
        (idiot.toUpper().contains(new StringBuffer("IWAN")))){
         return true;
      }else
         return false;
   }
 
   public String getDunderHead(){
      return "IW";
   }
 
   public char getNicompoop(){
      return 'a';
   }
 
   public char getDodo(){
      return 'N'
   }
 
   public static void main(String []args){
      I_M_N_S_WIPE var = new I_M_N_S_WIPE();
      String str = "AM "+"I "+"DODO?";
      
      String conc = getDunderHead()+getNicompoop()+getDodo();
      System.out.println("With no doubt the answer is: "+con.toUpper());
      
   }
}

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: need help regex ...Word Possibility ? Posted: Sep 28, 2005 7:57 AM
Reply to this message Reply
Sorry I forgot to pass in conc as a parameter to the
topmost method, here is the correction:
import java.io.*;
class I_M_N_S_WIPE{
   public boolean computeInterchangeable(String idiot, String knitwit){
      if(idiot.toUpper().contains(new StringBuffer("IWAN"))||
        (idiot.toUpper().contains(new StringBuffer("IWAN")))){
         return true;
      }else
         return false;
   }
 
   public String getDunderHead(){
      return "IW";
   }
 
   public char getNicompoop(){
      return 'a';
   }
 
   public char getDodo(){
      return 'N'
   }
 
   public static void main(String []args){
      I_M_N_S_WIPE var = new I_M_N_S_WIPE();
      String str = "AM "+"I "+"DODO?";
      
      String conc = getDunderHead()+getNicompoop()+getDodo();
      System.out.println("With no doubt the answer is: "+computeInterchangeable(con.toUpper()));
      
   }
}

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: need help regex ...Word Possibility ? Posted: Sep 28, 2005 4:04 PM
Reply to this message Reply
Kondwani,

You too patient and kind. If these guys are too lazy to even read your response and clarify the question (or homework assignment, as it were), not to mention so lazy that they expect you to send the answer to their email addresses rather than check back, where do you find the generosity to give such a nice answer?

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: need help regex ...Word Possibility ? Posted: Sep 30, 2005 1:09 AM
Reply to this message Reply
These jokers need to be clowned every now and again -
even if it takes a whole 5 minutes out of ones schedule,
I think its worth getting the point across. On the flip
side though you're right, there is no point responding
to garbage...

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: need help regex ...Word Possibility ? Posted: Sep 30, 2005 10:13 PM
Reply to this message Reply
Actually, on closer examination, I'm a little disappointed. Are you not a Java programmer? What's with String.toUpper()? Calling instance methods from a static method? What's String.contains()?

How about this solution:

class BankWords
{
   int [] data = { 0x51, 0x75, 0x69, 0x74, 0x20, 0x62, 0x65, 0x69,
                   0x6e, 0x67, 0x20, 0x73, 0x6f, 0x20, 0x6c, 0x61,
                   0x7a, 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x64,
                   0x6f, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f,
                   0x77, 0x6e, 0x20, 0x68, 0x6f, 0x6d, 0x65, 0x77,
                   0x6f, 0x72, 0x6b, 0x2e };
 
   private String decodeBankWords()
   {
      StringBuffer buffer = new StringBuffer();
      for( int i = 0; i < data.length; i++ )
         buffer.append( (char)data[i] );
      return buffer.toString();
   }
 
   public static void main(String []args)
   {
      BankWords bankwords = new BankWords();
      System.out.println(bankwords.decodeBankWords());
   }
}

Iwan Setyawan Herwanto

Posts: 4
Nickname: rainstorm
Registered: Sep, 2005

Re: need help regex ...Word Possibility ? Posted: Oct 2, 2005 7:33 AM
Reply to this message Reply
Thank to you all...
Especially to Kondwani....
Now i can complete my work... thank you very much...

best regard,
Iwan SH

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: need help regex ...Word Possibility ? Posted: Oct 2, 2005 10:28 PM
Reply to this message Reply
> Actually, on closer examination, I'm a little
> disappointed. Are you not a Java programmer? What's
> with String.toUpper()? Calling instance methods
> from a static method? What's
> String.contains()?
>
You're right some of the code is flawed. I should
have been calling those methods via the var. Was
kind of in a hurry though hence just wanted to
splurt out the general algorithm.

Did this guy really take that code seriously, notice
he just sent thank you's... I hope he hands it in...

Flat View: This topic has 15 replies on 2 pages [ 1  2 | » ]
Topic: NEED Programming HELP ASAP!! Previous Topic   Next Topic Topic: Applet filter won't work

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use