I have a string composed of letters and square brackets ONLY. The square brackets define groups of letters. One letter from each group can be chosen in each expansion. I need to expand these letters into its actual strings.
$str = 'ABCCDF[GH]IJJ[KLM]'
$sub = 'ABCCDFGIJJK';
$sub = 'ABCCDFHIJJK';
$sub = 'ABCCDFGIJJL';
$sub = 'ABCCDFHIJJL';
$sub = 'ABCCDFGIJJM';
$sub = 'ABCCDFHIJJM';
The solution should be in PHP, compatible with 7.2
Should use no external libraries, only core PHP
I expect a function with a string as input and an array of strings as a return
function (string $string) : array
Should work with strings like the example but no limit in the number of groups or in the number of letters in each group. Should be a generic function.
Could be a recursive function.
The letters between brackets are groups, and you can choose only one (1) of these letter for each expansion.
You should do the corresponding permutations
Other valid examples the function should solve are:
$str = 'AB[ST]DF[GH]IJJ[KLM]A'
$sub = 'ABSDFGIJJKA';
$sub = 'ABSDFHIJJKA';
$sub = 'ABSDFGIJJLA';
$sub = 'ABSDFHIJJLA';
$sub = 'ABSDFGIJJMA';
$sub = 'ABSDFHIJJMA';
$sub = 'ABTDFGIJJKA';
$sub = 'ABTDFHIJJKA';
$sub = 'ABTDFGIJJLA';
$sub = 'ABTDFHIJJLA';
$sub = 'ABTDFGIJJMA';
$sub = 'ABTDFHIJJMA';
A[BC]D should be expanded in:
Another example AA[DCF] should be expanded in:
Another example with many groups AF[RT]SD[ER]D should be expanded in:
One las example [AB]
Should be expanded in:
Strings without brackets are returned as is:
AABCDFGTY is expanded in AABCDFGTY
Examples of illegal (never expected strings) YOU SHOULD NOT HANDLE THIS CASES BECAUSE I TAKE CARE OF INPUT VALIDATION, THIS INFO IS ONLY FOR CLARITY:
[A[B]]CCDD -> never nested brackets
AB[CCD]FGG -> never groups with a repeated letter
ADFG$% HJ -> characters different from letters and square brackets
* The returned array elements order is not important
* There should not be exception handling in the input side. I take care of that. The input string is only letters [A-Z] and symbols '[' and ']'
* Groups could be at the very beginning and/or at the very end then '[AE]DDFFGV[FGH]' is a valid string to be parsed.
* Letters inside one group will never be repeated, for example, AB[CCD]E is not valid input and you don't need to check this case because I handle it.
21 freelance font une offre moyenne de $27 pour ce travail
HI, can help you in the project to break and manage the string to different way. please let me know when we can start working. Looking forward for your response. Thanks.
Hi! Assuming you want this wrapped as a funcion which you can call passing the raw string to it and getting back the array of output strings back, I have couple questions. 1) Intermittent spaces won't matter rega Plus
I have experience of Website in PHP, Laravel, CodeIgnitor, Wordpress, Opencart, Woocommerce, Photoshop, Adobe Illustrator . We also have experience of making Android,Window and iphone application with ionic & phonegap. Plus
Hi there. I able to start right now. Ping me. Thank you. With regards. Yegor. ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
Update: I finished creating the function (and tested it with all examples you gave). Choose me and I'll give you the PHP file immediately. Original Bid: Hello. I'm an expert in PHP programming. I can easily create code Plus
Hi, i can work with you into site topic and provide strong fast code thanksHi, i can work with you into site topic and provide strong fast code thanks
Hi there, Greetings from TechPlus! I've reviewed requirements & ready to Solve specific PHP string expansion problem. 5+ Years Expertise in : CMS (Wordpress, Magento, Shopify, OpenCart, Joomla, Drupal, Presta Plus
Hi, I am PHP coder any can deliver function. It's a kind of alphanumeric permutation. But 1 thing is not clear to me: You are saying that the group are valid when they are at the beginning or at the end. But in your Plus
Hi I am an Engineering undergraduate experenced in web development with php for more than 4 years. I can create you the required string using allowed characters from each [login to view URL] combining other. Relevant Skills an Plus
Please come on chat and provide me an opportunity , i have 5 year of experience in php and can convert letters into its actual strings according to your need , so please message me. Thanks
Hi, I can help you with that starting immediately and finishing the function in less than an hour. I have more than 4 years of PHP, JavScript, JQuery, CSS, and WordPress development. If you have any question, plea Plus
Dear client. I've read your project description carefully and very interested. Let's discuss over chat and get started. Waiting for your reply. Regards.
Hi. As a programmer with academic background, I can write such fuction within 15 minutes. Just drop me a message.
We Believe in Delivering Perfect Work and Providing Full Satisfaction to Our Client . We also Insure to Deliver the Work in the given Time Frame . we have highly Qualified Professionals in our team
Its a simple task to finish in 2 to 3 hours... accept the bi, i will start working on it right now and deliver it ASAP.
Hi, I can do this job for you. Please let me know when we need to start work on it so we can make it done asap. Looking forward to your response. Thanks.
This can be done very quickly. This specific problem takes me back to the earliest parts of my career when we would have coding challenges such as this.
After reading your entry, im fairly confident that I can help you with the function, I should be able to deliver it by today at around 10pm PST
Just talk to me and we will resolve this problem! In this case the solution is to see with a little more detail