c# - Match whole word containing numbers and underscores not between quotes -


i trying find right way regex:

\b([a-za-z]|_)+\b 

to not match whole words between quotes (' , "), so:

example_ _where // matches: example_, _where "not matched" // matches: , while // matches: while while 'this' // matches: while , 

additionally trying find out how include words containing numbers, not numbers, again:

this number 0 // matches: this, , number numb3r f1ve // matches: numb3r , f1ve example_ _where // matches: example_ , _where "not 9 matched" // matches: , while 'this' // matches: while , 

the goal try , match words valid variable names in common programming languages, without matching in string.

this should work:

"[a-za-z_0-9\s]+"|([a-za-z0-9_]+) 

the idea here is, if words surrounded ", won't record matches.

demo :)


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -