File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes generatinf pattern strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "generatinf pattern strings" Watch "generatinf pattern strings" New topic
Author

generatinf pattern strings

Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
can any one tell me how can i generate pattern strings of the following form:

"a.* .*a";
"a.* .*b";
"a.* .*c";
"a.* .*d";
"a.* .*e";
"a.* .*f";
"aa"
"ab"
"ac"
"ad"
"ae"
"af"
similarly for alphabets b,c,d...upto z

thanks for support
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi Fundupuneet,

I guess you try to find all permutations of a string consisting of all letters from the alphabet, right?

Here is an example in Java. I've not tested it but I'm pretty sure it works as described. Unfortunately the the shortest form to generate all permutations of a given string is mostly a recursive algorithm and therefore harder to understand. I hope you can figure out what it does at least to some degree.

Perhaps you can just google for more information about permutations in general if you'd like to know more about it.

Marco
Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
i didn't get that program,let me describe the problem more properly:
these are pattern strings
String patternStr= "a.* .*a";
String patternStr= "a.* .*b";
and so on as i mentioned above,i have to do also for each patternstring,a corresponding candidate like for pattern string(a regular expression)a.* .*a,i have candidate a a,now whenever that pattern is encountered in the input string ,i have to increment the count for the candidate that corresponds for the pattern string,how can i generate such correspondence,also how can i generate pattern strings ,here is the code i wrote,tell me how can do that job..
Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
i forgot the sample.txt contents:here are it's contents
a abc ac d cf
ad c bc ae
ef ab df c b
e g af c b c
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18840
    
  40

... and so on as i mentioned above,i have to do also for each patternstring,a corresponding candidate like for pattern string(a regular expression)a.* .*a,i have candidate a a,now whenever that pattern is encountered in the input string ,i have to increment the count for the candidate that corresponds for the pattern string,how can i generate such correspondence,also how can i generate pattern strings , ...


Can you elaborate exactly what you want? This description doesn't make much sense.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generatinf pattern strings