Skip to main content
added 791 characters in body
Source Link
Lats
  • 11
  • 4

Since I'm not that familiar with java, I don't know if there's a library somewhere that can do this thing. If not, does anybody have any ideas how can this be accomplished?

For instance I have a string "foo" and I want to change the letter f with "f" and "a" so that the function returns a list of strings with values "foo" and "aoo".

How to deal with it when there's more of the same letters? "ffoo" into "ffoo", "afoo", "faoo", "aaoo".

A better explanation: (("a",("a","b)),("c",("c","d"))) Above is a group of characters that need to be replaced with a character from the other element. "a" is to be replaced with "a" and with "b". "c" is to be replaced with "c" and "d".

If I have a string "ac", the resulting combinations I need are: "ac" "bc" "ad" "bd"

If the string is "IaJaKc", the resulting combinations are: "IaJaKc" "IbJaKc" "IaJbKc" "IbJbKc" "IaJaKd" "IbJaKd" "IaJbKd" "IbJbKd"

The number of combinations can be calculated like this: (replacements_of_a^letter_amount_a)(replacements_of_c^letter_amount_c) first case: 2^12^1 = 4 second case: 2^2*2^1 = 8

If, say, the group is (("a",("a","b)),("c",("c","d","e"))), and the string is "aac", the number of combinations is: 2^2*3^1 = 12

Since I'm not that familiar with java, I don't know if there's a library somewhere that can do this thing. If not, does anybody have any ideas how can this be accomplished?

For instance I have a string "foo" and I want to change the letter f with "f" and "a" so that the function returns a list of strings with values "foo" and "aoo".

How to deal with it when there's more of the same letters? "ffoo" into "ffoo", "afoo", "faoo", "aaoo".

Since I'm not that familiar with java, I don't know if there's a library somewhere that can do this thing. If not, does anybody have any ideas how can this be accomplished?

For instance I have a string "foo" and I want to change the letter f with "f" and "a" so that the function returns a list of strings with values "foo" and "aoo".

How to deal with it when there's more of the same letters? "ffoo" into "ffoo", "afoo", "faoo", "aaoo".

A better explanation: (("a",("a","b)),("c",("c","d"))) Above is a group of characters that need to be replaced with a character from the other element. "a" is to be replaced with "a" and with "b". "c" is to be replaced with "c" and "d".

If I have a string "ac", the resulting combinations I need are: "ac" "bc" "ad" "bd"

If the string is "IaJaKc", the resulting combinations are: "IaJaKc" "IbJaKc" "IaJbKc" "IbJbKc" "IaJaKd" "IbJaKd" "IaJbKd" "IbJbKd"

The number of combinations can be calculated like this: (replacements_of_a^letter_amount_a)(replacements_of_c^letter_amount_c) first case: 2^12^1 = 4 second case: 2^2*2^1 = 8

If, say, the group is (("a",("a","b)),("c",("c","d","e"))), and the string is "aac", the number of combinations is: 2^2*3^1 = 12

Source Link
Lats
  • 11
  • 4

Replace substring with a regex combination

Since I'm not that familiar with java, I don't know if there's a library somewhere that can do this thing. If not, does anybody have any ideas how can this be accomplished?

For instance I have a string "foo" and I want to change the letter f with "f" and "a" so that the function returns a list of strings with values "foo" and "aoo".

How to deal with it when there's more of the same letters? "ffoo" into "ffoo", "afoo", "faoo", "aaoo".