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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:37:08+00:00 2026-06-17T13:37:08+00:00

Mondays, however, how do I get a regex that will replace all \ that

  • 0

Mondays, however, how do I get a regex that will replace all \ that do not have a " after?

I have tried:

$toBeCleaned = preg_replace('/\\(?!")/',"\\\\",$toBeCleaned);

Which of course says:

preg_replace(): Compilation failed: unmatched parentheses at offset 5

Thing is I can get this to work on: http://www.solmetra.com/scripts/regex/index.php just fine.

However I modified it to:

$toBeCleaned = preg_replace('/\\\(?!")/',"\\\\",$toBeCleaned);

Which does not error out but at the same time, of course due to the escaping done, does not work.

I can’t seem to comprehend on a Monday morning why I can’t get it to do its job.

  • 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-17T13:37:09+00:00Added an answer on June 17, 2026 at 1:37 pm

    After running @hank’s regex by actually using a word to replace the text I found out my regex was working pefectly fine it just wasn’t replacing correctly. So I changed it to:

    $toBeCleaned = preg_replace('/\\\(?!")/',"\\\\\\",$toBeCleaned);
    

    Which does actually work.

    I am accepting this answer too because of the problems that can occur from using negated character classes as mentioned on this page: http://www.regular-expressions.info/charclass.html

    I do hate Mondays.

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

Sidebar

Related Questions

I have a model that contains datefield . I'm trying to get query set
I have a database from which I want to query and display only that
I have combined two tables using union all . However, the produced data has
I have a page that loads a dynamic number (however many in the database
I have a job that must execute each monday. This job run in a
I am trying to get this to output all the weekdays (MON-FRI) between 5/16/2010
On Mac OSX 5.8 I have a Java program that runs at 100% CPU
I have tried to do this without bothering the experts and have read numerous
I have a list of day names (typically Monday-Saturday, though special cases apply) that
Say I have a result set that can contain one or more values, but

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.