php - Split code by semicolon -


i parse source code. read line line, 1 line can contain more 1 command.

i wonder if possible split line semicolons, those, aren't in '...' or "..." blocks.

answering question: split line semi-colon not inside double or single quoation marks, can use following regex:

(?:'[^']*'|"[^"]*")(*skip)(*fail)|; 

it find ; outside "..." , '...'.

see demo.

however, please consider using appropriate tools task taking up.


Comments

Popular posts from this blog

python - Installing PyDev in eclipse is failed -

PHP OOP-based login system -

c# - Nested Internal Class with Readonly Hashtable throws Null ref exception.. on assignment -