Need understanding this Ruby Regex code -


i attempting become better acquainted ruby regex , came accros in 1 of codewars.com answers.

my current comprehension of regex follows. \w means any non-word character. assuming pipe symbol means effect of between every character , think underscore means all underscores between charecters.

am close? criticism welcomed. thank you.

/\w|_/ 

in regex: /\w|_/, vertical bar "or". in ruby, _ word character (e.g., abc_def valid word in ruby), , not matched \w. regex above matches non-word character or underscore. can test out @ rubular.com.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -