Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

anagrams in JavaScript required help for home work

here is my requirement

const input = 'abcadbca';
const required = 'bca';

the input contains 3 possibility anagrams as:abc,bca,bca;
is this all can be selected using regexp?
i tried it, but got not result:

const str = 'abcadbca';
const reg = str.match(/(a|b|c)/g);

console.log(reg);

result expectation: [a,b,c,][b,c,a],[b,c,a];
result should be [a,b,c],[b,c,a] – first 2 match are overlapping so first match is taken for the account.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No

A regexp will not formulate the various anagrams.

Note

Your requirement and expectation are different. Maybe you can explain your homework question more clearly ? What was the original wording given to you?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading