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

  • SEARCH
  • Home
  • 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 7906505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:00:20+00:00 2026-06-03T11:00:20+00:00

Alright, this problem seems to be way above my head! I have this code:

  • 0

Alright, this problem seems to be way above my head!

I have this code:

$request=preg_replace('$(^'.str_replace('$','\$',$webRoot).')$i','',$requestUri);

This throws me an error:

preg_replace(): No ending delimiter ‘$’ found

But here’s the thing, that ending delimeter is certainly there.

After that function call I echoed out the following:

echo $webRoot;
echo $requestUri;
echo '$(^'.str_replace('$','\$',$webRoot).')$i';

This is the result of those echoes:

/
/en/example/
$(^/)$i

What is funny is that if I do this directly:

preg_replace('$(^/)$i','',$requestUri);

..it works. But this also fails:

$tmp=str_replace('$','\$',$webRoot);
preg_replace('$(^'.$tmp.')$i','',$requestUri);

And just to be thorough, I also tested what echo $tmp gives, and it does give the proper value:

/

Is it a bug in PHP in Windows? I tried it out on Linux server and it worked as expected, it didn’t throw this error. Or am I missing something?

Just to make sure, I even updated PHP to latest Windows version (5.4.2) and the same thing happens.

  • 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-03T11:00:23+00:00Added an answer on June 3, 2026 at 11:00 am

    Well, I personally would use another character as a delimiter like ‘#’ since the $ char is a regexp special char which matches at the end of the string the regex pattern is applied to. That said the few times I had to work on windows servers I found that every regular expressions has to be passed through preg_quote function, nevermind if it contains or not regexp special chars.

    $request=preg_replace('#(^'.preg_quote($webRoot).')#i','',$requestUri);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, this problem is a little complicated, so bear with me. I have a
Alright, this is a weird problem I'm having. I have two pages, which are
Alright, this one (3a; sample problem with provided answer) has got me scratching my
Alright I know this is more than likely a amateur question but I have
Alright, this one's interesting. I have a solution, but I don't like it. The
Alright, this is melting my brain. It might have something to do with the
Alright, here is my problem i'm trying to solve. I have an index page
Alright so i found a code and it seems to be working but I
Alright. I thought this problem had something to do with my rails app, but
Is it alright to do this? $author = strtolower($_SESSION['valid_username']); I want to enter all

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.