regex - Php: how could I remove any character, or whole string from a string, excluding the ones between quotes? -


this thread similar, dont want remove white spaces, characters. example, im trying remove new lines (0x10 or 0x13 characters) string, if around ' ' or " " must remained untouched. im using php.

you replacing following expression:

("[^"]*"|'[^']*')|[\r\n]+ 

with content of first capturing group: $1.

this works capturing quote , replacing self, or matching things want remove, , replacing them empty string.

if want handle backslash escapes too, use following expression instead in same replacement:

("(?:[^"\\]+|\\.)*"|'(?:[^'\\]+|\\.)*')|[\r\n]+ 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -