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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:27:31+00:00 2026-06-18T05:27:31+00:00

I got a little problem already… I only want to replace some names with

  • 0

I got a “little” problem already…
I only want to replace some names with other names or something.
It works fine so far, but with some names I got a problem.

For example I want to replace "Cho" with "Cho'Gath",
but of course I don’t want to replace "Cho'Gath" with "Cho'Gath'Gath".

So therefore I created this regular expression, and replace all "Cho"‘s except of "Cho'Gath":

/\bCho(?!.+Gath)\b/i

This works and it doesn’t replace "Cho'Gath", but it also doesn’t replace "Cho Hello World Gath" … that is my first problem!

The second one is follwing: I also want to replace all "Yi", but not "Master Yi", so I tried the same with the following regular expression:

/\b(?!Master.+)Yi\b/i

This doesn’t replace "Master Yi", okay. But it also doesn’t replace "Yi", but it should do! (I also tried /\b(?!Master(**\s**))Yi\b/i but this also doesn’t work)

So far I don’t know what to do know… can anyone help me with that?

  • 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-18T05:27:32+00:00Added an answer on June 18, 2026 at 5:27 am

    Your first problem is easily solved if you replace .+ with the actual character that you want to match (or not to match): ', but let’s have a look at the second one, this is quite interesting:

    I also want to replace all “Yi”, but not “Master Yi”, so I tried the
    same with the following regular expression:

    /\b(?!Master.+)Yi\b/i
    

    This is a negative lookahead on \b. The expression does match a single “Yi”, but look what it does with “Master Yi”:

    Hello I am Master Yi
                     ^
                     \b
    

    This boundary is not followed by “Master” but followed by “Yi”. So your expression also matches the “Yi” in this string.

    The negative lookahead is quite pointless because it checks if the boundary that is directly followed by “Yi” (remember that a lookahead assertion just “looks ahead” without moving the pointer forward) is not directly followed by “Master”. This is always the case.

    You could use a lookbehind assertion instead, but only without the (anyways unnecessary) .+, because lookbehind assertions must have fixed lengths:

    /\b(?<!Master )Yi\b/i
    

    matches every “Yi” that is not preceded by “Master “.

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

Sidebar

Related Questions

Got a little problem in my code, the query works fine if I manually
i`ve got a little problem with LINQ. I read out some information via XML-RPC.
I've created a simple class and got a little problem: I just want to
got a little problem with MBProgressHUD. I have a webview and want to display
I got a little problem. Sometimes, when I try to call the following code,
I got a little problem, I got a code, that reads all pixels and
I got a little problem, it seems simple (personally I think it is), but
I've got a little problem using WPF Dispatcher Timer. On each timer tick my
i've got a little Problem regarding the AIF-Service in Dynamics Ax when sending a
I'm playing around with error handling and got a little problem. I connect with

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.