如何从字符串中删除空格和下划线?
Input String:
s:"Monday comes_after Sunday";
Expected Output:
"MondaycomesafterSunday"
答案 0 :(得分:5)
要查看https://code.kx.com/v2/kb/regex/的特殊字符部分
q)s:"Monday comes_after Sunday";
q)ssr[s;"[ _]";""]
"MondaycomesafterSunday"
可以使用,但是如果只删除字符,通常会更快
q)s except " _"
"MondaycomesafterSunday"
q)\ts:100000 s except " _"
90 816
q)\ts:100000 ssr[s;"[ _]";""]
691 1072