Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 877331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:35:21+00:00 2026-05-15T11:35:21+00:00

I’ve been trying to find a string in PHP that matches something like this:

  • 0

I’ve been trying to find a string in PHP that matches something like this:

Currently I’ve tried something like this;

<()\?php eval(^>>

but it dosen’t seem to get the string correctly.

edit: I forgot to add that I need to grab all the text form “” and it spans multiple lines.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:35:21+00:00Added an answer on May 15, 2026 at 11:35 am

    Why not just use Select-String?

    ls *.php | Select-String "<?php eval"
    

    The pattern given to Select-String is read as a regular expression. You can do plain-text matching by specifying the simpleMatch switch:

    ls *.php | Select-String "<?php eval" -simpleMatch
    

    Here’s the command to get the live help for PowerShell regular expressions:

    get-help about_regular_expression
    

    EDIT:

    Ah, you didn’t specify in your question that you were doing a REPLACE operation. This is a bit different, especially since it spans multiple lines. I would suggest something like this:

    # Retrieve file as a single string.
    $contents = [string]::Join("`n", $(Get-Content path\to\file.php))
    
    # Now replace.
    $replaced = $contents -replace '(?s)(<\?php eval\()(.*?)(\)\?>)', '$1neweval$3'
    

    So what this is doing is looking for <?php eval(, then LAZILY (important!) looking for )?>, all in single-line mode, so newlines are matched in the .*? portion. (Slashes before the question marks and parens to escape them.) It then replaces all matches with group 1 (in this case, <?php eval(), some text, then group 3 (the )?>). You can make the grouping as complex as you need to to collect information from within the match.

    Also, because you are trying to use regex to parse a language, instead of a language parser, there are lots of cases where this can go horribly, horribly wrong. Just be aware, and don’t clobber your files until you’ve verified that the output is correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 463k
  • Answers 463k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You may want to try 2 Firefox add-ons. They are… May 16, 2026 at 12:49 am
  • Editorial Team
    Editorial Team added an answer Apologies for the slow response. My problem was that I… May 16, 2026 at 12:49 am
  • Editorial Team
    Editorial Team added an answer Typically use another common method - a "construction helper" as… May 16, 2026 at 12:49 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.