javascript - Match parts of code -


i'm trying match parts of code regex. how can match var, a, =, 2 , ; from

"var = 2;" 

?

i believe want regexp: /\s+/g

to break down: \s selects non-whitespace characters, + makes sure selects multiple non whitespace characters (i.e. 'var'), , 'g' flag makes sure selects all of occurrences in string, , instead of stopping @ first 1 default behavior.

this helpful link playing around until find right regexp: https://regex101.com/#javascript


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -