ARta234
ARta234

Reputation: 3

Find a character within quotes, using preg_replace

I have a string:

106;"LORDAL La Manicure, ser;um do manuzi, wzrost, 5 ml";301*04*334;46;"loksx-la-mainusttej-wzroxst-5-ml";"";"";19.51220;"";"";"thumb23_9671ds359.png"

I want to replace all semicolon (;) characters that are within paired quotes. In the example above I only what to remote the semicolon in: "ser;um". After replacement it should look like this:

106;"LORDAL La Manicure, serum do manuzi, wzrost, 5 ml";301*04*334;46;"loksx-la-mainusttej-wzroxst-5-ml";"";"";19.51220;"";"";"thumb23_9671ds359.png"

I need use a preg_replace function, but I don’t know how to define a pattern.

Upvotes: 0

Views: 57

Answers (1)

alpha bravo
alpha bravo

Reputation: 7948

you could use this pattern

;(?!(([^"]*"){2})*[^"]*$)

Demo

Upvotes: 1

Related Questions