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

The Archive Base Latest Questions

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

Here is my problem: Using preg_replace(‘@\b(word)\b@’,’****’,$text); Where in text I have word\word and word

  • 0

Here is my problem:

Using preg_replace('@\b(word)\b@','****',$text);

Where in text I have word\word and word, the preg_replace above replaces both word\word and word so my resulting string is ***\word and ***.

I want my string to look like : word\word and ***.

Is this possible? What am I doing wrong???

LATER EDIT

I have an array with urls, I foreach that array and preg_replace the text where url is found, but it’s not working.

For instance, I have http://www.link.com and http://www.link.com/something

If I have http://www.link.com it also replaces http://www.link.com/something.

  • 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-13T17:10:45+00:00Added an answer on June 13, 2026 at 5:10 pm

    You are effectively specifying that you don’t want certain characters to count as word boundary. Therefore you need to specify the “boundaries” yourself, something like this:

    preg_replace('@(^|[^\w\\])(word)([^\w\\]|$)@','**',$text);
    

    What this does is searches for the word surrounded by line boundaries or non-word characters except the back slash \. Therefore it will match .word, but not .word\ and not `\word. If you need to exclude other characters from matching, just add them inside the brackets.

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

Sidebar

Related Questions

I have a problem using JSON and arrays. Here is my code: while($row =
Using Rational ClearCase v. 7.0.1.1 with UCM, I have a problem here when using
I have a problem with using a pointer to function in C++. Here is
here is the problem. I have one PC using VS2008 (SP1 ) and another
So here is my problem. I want to redirect name.domain.com/trips/1 to domain.com?username=name&trip=1 using modrewrite.
I've got a problem using different layouts for list items in my project. Here
Here is my problem: I export a database A_DB using export function of Phppgadmin.
Here is the problem... For school project I need to write parallel application using
So here's my problem. I'm currently working on a PhoneGap application using jQuery Mobile
Okay, here is my problem... I created a Data Layer using the RTM Fluent

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.