freecodecamp.cn icon indicating copy to clipboard operation
freecodecamp.cn copied to clipboard

Check for Palindromes 这个怎么写呢

Open wxlbobo opened this issue 9 years ago • 7 comments

Challenge Check for Palindromes has an issue. User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function palindrome(str) {
  // Good luck!
  var re = // ;
  str.replace(re,function(){
  });
  return true;
}



palindrome("eye");

wxlbobo avatar Apr 14 '17 06:04 wxlbobo

这题主要是需要学会正则,推荐你去regexr.com练习正则。 如果想看提示和解法,S1ngS1ng在wiki里面写的很详细哦!

wudifeixue avatar Apr 15 '17 18:04 wudifeixue

去W3C看一下正则表达式的相关方法,这里推荐使用replace(/[^a-z0-9]/g, "")来将所有除了字母和数字以外的文字和符号全部替换[^a-z0-9]中^是取反的意思,a-z,0-9分别代表字母a到z和数字0到9

TheFlashinchina avatar Apr 19 '17 06:04 TheFlashinchina

@wxlbobo 以后,这样的问题不要开 issue。在 gitter 讨论组提问就行

S1ngS1ng avatar Apr 19 '17 08:04 S1ngS1ng

if(str=="0_0 (: /-\ :) 0-0"){ return true; } 这点这样就可以过了?

Androiderof541 avatar Mar 18 '18 14:03 Androiderof541

@Androiderof541 也只能通过一个测试而已

S1ngS1ng avatar Mar 19 '18 19:03 S1ngS1ng

@S1ngS1ng 这也是一个知识点吧

Androiderof541 avatar Mar 20 '18 02:03 Androiderof541

去聊天室问这种问题

Brand4 avatar Mar 20 '18 03:03 Brand4