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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:00:41+00:00 2026-06-02T06:00:41+00:00

I am having problems grabbing some text using preg_replace() in php. I am just

  • 0

I am having problems grabbing some text using preg_replace() in php. I am just trying to remove all text that starts with a http|https|www up until the first whitespace character. I am currently using:
(http|https|www)\S+
as my regex in preg_replace(). However I am getting this error when running the code:
Warning: preg_replace(): Unknown modifier ‘\’
I can use this same regex in a text editor, e.g. Sublime Text 2 with no problem. Any ideas why I am getting this error? Is there another way to grab the text I am looking for with a regex?

Thanks for any help.

  • 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-02T06:00:43+00:00Added an answer on June 2, 2026 at 6:00 am

    You must delimit your regular expressions. This is usually a slash (/), but can also be a pair of parentheses. After the second delimiter can follow a number of delimiters (multi-line regex, ignore white-space, case-insensitive, etc.). \ is not a valid modifier, and thus, PHP complains.

    Modify your regex as follows:

    preg_replace('/(http|https|www)\S+/', …, …);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems passing an integer array to an MVC controller. I'm grabbing
I'm having some problem's grabbing a response stream from a request that returning status
Having problems deserializing some xml into an object in C#. The error that I
Im having problems getting some text in a dropdown menu under each other. Any
Im having problems reading text files in a php loop. This is an easier
Having problems with a small awk script, Im trying to choose the newest of
im having problems starting a codeigniter project, the problem is that when i do
I have started having problems with my VPS in the way that it would
I'm having problems compiling the following program. I'm using gcc -framework Foundation inherit8.1m and
I'm having problems with some code to create a CDialog based window. The code

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.