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

  • Home
  • SEARCH
  • 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 8700017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:05:29+00:00 2026-06-13T02:05:29+00:00

I need a regex to replace all symbols surround by a letters or numbers

  • 0

I need a regex to replace all symbols surround by a letters or numbers only. With a space, I’ll be using C# to run the expression and I’m OK with the part just stuck on the regex part.

So after the replacement the following

  1. Type-01 would be Type 01
  2. 01)* would still be 01)*
  3. -Category:Toys would still be -Category:Toys
  4. White:Back would be White Black

Current Expression

(?<=\w)[^a-zA-Z0-9Category:]+(?=\w)

Input string is

-Category:Toys AND (Teddy Bear Type-01*) OR (Teddy Bear White:Black)

Required output

-Category:Toys AND (Teddy Bear Type 01*) OR (Teddy Bear White Black)

But what I’m getting is

-Category:Toys AND Teddy Bear Type 01 OR Teddy Bear White:Black)

Not sure if I’m just missing some thing simple or just got the wrong end of the stick

  • 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-13T02:05:30+00:00Added an answer on June 13, 2026 at 2:05 am

    You can’t put words into a character class. All characters there will be added to that class, the order doesn’t matter.

    I am not sure if it is sufficient for you, but for your example, this will work:

    (?<=\w)[^a-zA-Z0-9*:()\s]+(?=\w)
    

    and replace with a single space.

    I would make it also more Unicode style:

    (?<=\w)[^\p{L}0-9*:()\s]+(?=\w)
    

    Where \p{L} is a Unicode property for a letter in any language.

    See it here on Regexr

    Update:

    If you want to keep the colon if there is “Category” before you could do it like this

    (?<=\w)(?:[^a-zA-Z0-9*()\s:]+|(?<!Category):)(?=\w)
    

    See it on Regexr

    I added the colon to the negated character class to say don’t replace the colon. Then I added an alternative to say: replace the colon, but only if there is not “Category” before.

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

Sidebar

Related Questions

I need to use Regex.Replace to remove all numbers and signs from a string.
I need to do a regex find and replace on all the files in
I need to replace some value in given text using c# preferably using regex
I have been using the following regex to replace all punctuation in a string:
Possible Duplicate: regex replace all ignore case I need to replace all occurrences of
I need to to a RegEx search and replace of all commas found inside
Problem I need to replace all asterisk symbols('*') with percent symbol('%'). The asterisk symbols
i need a regex to replace a string. <span class=\Translation\ lang=\ThisLanguage\> with this one:
I need a regex to use in Java to replace a String with UNKNOWN
I need to do use php/regex to replace this: {{image-4-m}} to this: <img src=4.jpg

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.