Skip to content

Instantly share code, notes, and snippets.

@chrdek
Created April 13, 2019 15:08
Show Gist options
  • Save chrdek/4cef0aedf10b7e82e48fa963e3707b87 to your computer and use it in GitHub Desktop.
Save chrdek/4cef0aedf10b7e82e48fa963e3707b87 to your computer and use it in GitHub Desktop.
Node sample regexp
#!/bin/bash
# Samples for Node set 1..
# ^(app\.js)|^(app\.[a-zA-Z0-9]+\.js)
ls | grep -E "app.[a-zA-Z0-9]+|app[0-9]{1,3}.js"
# ^(node_)[a-z0-9]+(.tmp)
ls | grep -E "node_[a-zA-Z0-9]+.tmp"
# %APPDATA%\npm-cache\_logs
# [0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}_[0-9]{2}_[0-9]{2}_[0-9]{3}Z-(debug\.log)
ls | grep -E "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}_[0-9]{2}_[0-9]{2}_[0-9]{3}Z-(debug.log)"
# %APPDATA%\npm-cache
ls -R | grep -E "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}_[0-9]{2}_[0-9]{2}_[0-9]{3}Z-(debug.log)"
ls -R | grep -E "[a-zA-Z0-9]+(.json){1}"
##########
# Samples for Node set 2..
# (app\.set){1}(\()('|")[a-zA-Z0-9\-]+('\,|"\,)('|")[0-9A-Za-z\-]+('|")
# [^(app\.set){1}(\()('|")]([a-zA-Z0-9\-]+)
cat -n <js_file> | grep -E "^[0-9]{1,5}|app.set{1}"
cat -n <js_file> | grep -E "^[0-9]{1-5}|app.use{1}"
# [^=][a-z]+[^\w]$
# (module\.exports){1}|[^=][a-z]+[^\w]$
# (module\.exports){1}|[^=]+[^\w]$
cat -n <js_file> | grep -E "^[0-9]{1,5}|module.exports ="
cat -n <js_file> | grep -E "^[0-9]{1,5}|( =|= |=)require"
# (err|error)(\.|\,|:|\S)|([(\()]+(e)[(\))]+)|(err)
cat -n <js_file> | grep -E "^[0-9]{1,5}|(err|error)(\.|\,|:|\S)|([(\()]+(e)[(\))]+)|(err)"
# ^[(err|error){1}]|^[(EventEmitter\.){1}]|^[(Exit Status){1}]
cat -n <log_file> | grep "error"
cat -n <log_file> | grep "EventEmitter."
cat -n <log_file> | grep "Exit Status"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment