Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generatinf pattern strings

 
Puneet N Vyas
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20894
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic