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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:30:37+00:00 2026-05-25T21:30:37+00:00

I have a regular expression that should be matching some string of the form:

  • 0

I have a regular expression that should be matching some string of the form: src=”/blkjad.dafsdf”>. It looks like this: (src|href)(\s*)?=(\s*)?(\”|\’)/([^/].*?)\4.

While this works fine on one site I’m running, it fails consistently on another, built in Cake. Here’s another failing Regex => ‘/(“)/’ which should be matching any double quotation in the line.

I’m at a loss right now. One of the senior developers where I work just took a look at it and basically shook his head. Unfortunately, I’m not that proficient with Cake, and I can’t seem to find any similar problems online. Any ideas?

edit: For the record, the failing regex uses preg_match_all, while the other (identical/ working regex) uses preg_replace. Here is some relevant code.

$regex['php'] = '/(src|href)(\s*)?=(\s*)?(\"|\')\/([^\/].*?)\4/';

$php = htmlspecialchars(file_get_contents(sprintf('/home/x/x/x/x/x/%s.%s', $string,    $extension)));                                                  echo $php;

 if (preg_match_all($regex['php'], $php, $out)){
    echo sizeof($out);
    echo nl2br(print_r($out, true));
 } else {
    echo 'Doesn\'t work';
 }
  • 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-25T21:30:37+00:00Added an answer on May 25, 2026 at 9:30 pm

    I think the problem comes from the htmlspecialchars() call.

    As stated in the PHP documentation

    The translations performed are:

    • ‘&’ (ampersand) becomes ‘&’
    • ‘”‘ (double quote) becomes ‘"’
    • when ENT_NOQUOTES is not set. “‘” (single quote) becomes ‘'’ only
    • when ENT_QUOTES is set. ‘<‘ (less than) becomes ‘<‘ ‘>’ (greater
      than) becomes ‘>’
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this regular expression ([A-Z], )* which should match something like test, (with
I have this Regular Expression that matches the following strings: <!-- 09-02-2009 ---> <!--
i have a string like that: [variable = value][variable2=value2][Some text inside] I need to
I have a regular expression ^(?=.*?[A-Za-z])\S*$ which indicates that the input should contain alphabets
I have a Python regular expression that contains a group which can occur zero
I have a Python regular expression that matches a set of filenames. How to
I have the following regular expression that works fine in perl: Classification:\s([^\n]+?)(?:\sRange:\s([^\n]+?))*(?:\sStructural Integrity:\s([^\n]+))*\n The
Does anyone have a regular expression handy that will match any legal DNS hostname
Over the years I have slowly developed a regular expression that validates most email
I have a regular expression ^[a-zA-Z+#-.0-9]{1,5}$ which validates that the word contains alpha-numeric characters

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.