Skip to content

Instantly share code, notes, and snippets.

@luochen1990
Last active February 15, 2017 01:51
Show Gist options
  • Save luochen1990/444016ea84d0a761842d to your computer and use it in GitHub Desktop.
Save luochen1990/444016ea84d0a761842d to your computer and use it in GitHub Desktop.
Most Used Regex in JavaScript
capitalize = (s) -> s.replace /(?:_|^)([a-z])/g, (_, c) -> c.toUpperCase() # 'hello_world' to 'HelloWorld'
uncapitalize = (s) -> s.replace /([A-Z])/g, (_, c) -> '_' + c.toLowerCase() # 'HelloWorld' to 'hello_world'
is_chinese_char = (c) -> /[\u4E00-\u9FA5\uF900-\uFA2D]/.test c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment