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 9069081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:20:10+00:00 2026-06-16T17:20:10+00:00

Can anyone help me with regex problem. Im making a script to go through

  • 0

Can anyone help me with regex problem. Im making a script to go through all my .php files and get all strings passed to certain function. I need to match this cases:

/* Double quotes */
function("some string"); // Match: some string
function("some \"string\""); // Match: some "string"
function("some 'string'"); // Match: some 'string'

/* Single quotes */
function('some string'); // Match: some string
function('some \'string\''); // Match: some 'string'
function('some "string"'); // Match: some "string"

Function can also accept parameters after string, so it also needs to match this cases:

/* Additional parameters */
function("some string", "param"); // Match: some string
function("some string", $param); // Match: some string

So essentially, param can be either a string (quoted or double quoted) or unquoted variable.
I need to get string only from first parameter of function, regardless if second parameter exists or is quoted in any way…

Thanks in advance…

  • 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-06-16T17:20:12+00:00Added an answer on June 16, 2026 at 5:20 pm

    Your particular example was successfully processed with…

    preg_match_all('#\\(\\s*("((\\\\.|[^"])+)"|\'((\\\\.|[^\'])+)\'),?#s', $test, $matches);
    

    Here’s ideone demo.

    Explanation: we try to match opening parenthesis (thankfully, it’s PHP; it’d be far more difficult in Ruby), followed by any number of whitespace characters, followed by…

    • either "(\\.|[^"])+"
    • or '(\\.|[^'])+'

    … followed by optional comma.

    Each of this sequences covers both ‘special characters’ (escaped with slash) and ‘normal ones’ (that are not the same as delimiters).

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

Sidebar

Related Questions

Can anyone help me with a quick regex problem? I have the following HTML:
Can anyone help me with creating a regex for variables in java so that
Can anyone help me to get good WordPress interview questions and answers. Any link
Can anyone help me with the script to refresh the page once . I
I wonder if anyone can help with a jQuery problem I am having. I
am having problems with some Regex code can anyone help. I have the following
So I have this regex problem and wondered if anyone could help me out?
Can anyone help me with a regex for the standard password field for the
Can anyone help me with a regex to turn: filename_author to author_filename I am
Can anyone help me with this regex? I need something which will ALLOW: 0-9

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.