Advertisement
natalyayemelyanova

Алексей Бездетко 4

Apr 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. const isStringConverted = (s1,s2) =>{
  2. if(!s1.length&&!s2.length) return true;
  3. let noSpacesS1 = s1.replace(/\s/g,'').toLowerCase();
  4. let noSpacesS2 = s2.replace(/\s/g,'').toLowerCase();
  5. console.log(noSpacesS1,noSpacesS2);
  6. if(noSpacesS2.length>noSpacesS1.length) return false;
  7. return [...noSpacesS2].every(
  8. char=>{
  9. let pattern = new RegExp(char.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),'g');
  10. console.log(pattern,noSpacesS1,noSpacesS1.match(pattern));
  11. return noSpacesS1.match(pattern)?noSpacesS1.match(pattern).length>=noSpacesS2.match(pattern).length:false;
  12. });
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement