.net - Using Powershell regex to find PHP strings like "<?php eval " -


I am trying to find a string in PHP which matches something like this:

Currently I have tried to do something like this;

& lt; () \? Php eval (^

But it does not seem to get the string properly.

EDIT: I forgot to add that I wanted to catch all the text form It is required and spreads to many lines.

Why not select only the string?

  ls * .php | selection-string " 

selection-string pattern given regular Expressions are read as you type. You can match plain-text by specifying switch:

; PowerShell
  ls * .php | select-string " 

> get-help about_regular_expression

edit:

< P> Ah, you did not specify in your question that you were doing a reload operation, it is a bit different, especially since it spreads several lines, I will give some suggestions like this:

  # File one string Retrieve $ content = [string] :: Join ("` n ", $ (Get-content path \ to \ file.php)) # Change now $ Replace = $ contents -replace '(? S) (& lt; \? Php eval \ () (. *?) (\) \? & Gt;),' $ 1neweval $ 3 ' 

So what is this doing & lt ;? Php eval (, then lazily (important!) )? & Gt; Looking for , all single-line modes, therefore new lines, . *? matches in the part. (To avoid them slash before question marks and feet.) It then replaces all matches with group 1 (In this case, ), some text, Then group 3 (the ) & gt; ). You can create grouping as complex, as you need to collect information from within Milan.

Besides, because you are trying to use regex to parse the language instead of a language parser, there are so many in cases where it can be very badly wrong. Be aware, and unless you have verified that the output is correct, then do not stop your files.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -