How to use regular expressions to find specific text?

The point is that this text should be out of line, that is, outside the quotation marks. For example you need to find a design (comment) /*sample*/ in php code. Most importantly, you need to do so, how would the php interpreter.
For example
"f sfs\"df/*sample*/sdf".'p\'and"in/*sample*/pvpv'/*sample*/ $hfhfh=5;
the first and second /*sample*/ should be skipped, and the third taken. The same should be taken into account escaping of quotes as a single and a double. It may have been somewhere finished the regular season not to write it from scratch, and then I have the head already around goes?
September 19th 19 at 13:00
2 answers
September 19th 19 at 13:02
The php interpreter parses. Regular expression to solve your problem it is impossible (at least with 100% result).
September 19th 19 at 13:04
Maybe in two phases:
1) preg_replace, what's inside the quotes is replaced by the void
2) preg_match_all
not suitable, since these comments I have to cut and save the file. - Luther_Pacocha commented on September 19th 19 at 13:07
: well, it happens, cut out the quotes, only the comments remain outside the quotes, look for them and keep - johathan.Boyle2 commented on September 19th 19 at 13:10
: I need a regular season. In General a single action. The fact that the regular season can enter the user and my script will substitute it into the function preg_replace, I can't be sure how many actions you need to perform, so you do only one thing. - Luther_Pacocha commented on September 19th 19 at 13:13
I left my bike for building php projects. I just have some features that cannot be resolved through other collectors, or I just don't know. - Luther_Pacocha commented on September 19th 19 at 13:16

Find more questions by tags Regular expressionsPHP