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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:37:21+00:00 2026-05-28T02:37:21+00:00

I hav especific need of removing word from string, But I am having problem

  • 0

I hav especific need of removing word from string, But I am having problem when that word has dot (.) character.

Lets see here is the string and what I have tried so far?

$result = 'Hello Ka Kashish.';
$result = preg_replace('/\bKa\b/i', '', $result);

I will get the expected result 'Hello Kashish.'

But if the string is like below, It is not working

$result = 'Hello Ka. Kashish.';
$result = preg_replace('/\bKa.\b/i', '', $result);

It gives me result 'Hello Ka. Kashish.'
Why this .(dot) is not working?
Please give me solution.

And if I can achive this word removal in any other way, pLease let me know.
I want to remove only word not set of charaters, as ‘Ka’ word will be removed, but ‘Ka’ will not be removed from ‘Kashish’.
Please help me.

Thanks in Advance

  • 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-28T02:37:21+00:00Added an answer on May 28, 2026 at 2:37 am

    This is because the dot can match any character.

    The problem, too, is that \b really matches a word frontier, ie a position where a word character is followed by a non word character, or a non word character is followed by a word character. But as a dot is not a word character and neither is a space for that matter, it won’t match.

    Maybe you should try that instead:

    preg_replace('/\bKa(\W|$)/i', '', $result)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have specific problem. I need to extract domain names from active directory and
I have an HTML string that has the following form: <tr valign=top><td colspan=2 style=padding-bottom:5px;text-align:
I hav used uigraphics cgcontext to draw line on touch...but my line is not
If using subsonic, i know you hav to close a datareader. but what if
I have specific classes that i need to load. There name are stored in
I have an Abstract Domain Class in Grails wich has fields that all the
How can I validate that an element has specific attribute and attribute must have
I know that what I'm trying to do is bad idea, but I have
I need to store a bunch of email addresses each having a label (primary
I created an HtmlHelper method called DisplayListBoxFor that will need display a textual representation

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.