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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:54:46+00:00 2026-06-18T09:54:46+00:00

I’am trying to filter a string using Regex, I want to filter the PÑ

  • 0

I’am trying to filter a string using Regex, I want to filter the PÑ combination out of my string, and also some Seperate P‘s, However in the string that gets provided are also some parts of text like: PB00121324, I want to keep that P.

this is the string:

PB014EC8F;1359300102;NL1200000001 ;Ey³ PÑ PÑ B014EC8F;1359 P B014EC8F;1359

I want to filter out: seperate P‘s and PÑ‘s

So that the output would be this:

PB014EC8F;1359300102;NL1200000001 ;Ey³

I’am now using this code:

string CleanString = Regex.Replace(DirtyString, @"[\\PÑ?]", "");

The problem is that it will result this:

B014EC8F;1359300102;NL1200000001 ;Ey³

instead of this:

PB014EC8F;1359300102;NL1200000001 ;Ey³

Does anybody know the Regex for this?

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-06-18T09:54:48+00:00Added an answer on June 18, 2026 at 9:54 am

    You can use \b to find a word boundary so for example the regex \bP\b will find a P in isolation.

    With \bP\b…

    Input Hello P Goodbye -> P Matches as it is adjacent to spaces (non-word characters)

    Input HelloP Goodbye -> P does not match as it is adjacent to the previous word

    Input Hello.P.Hello -> P matches as it is adjacent to non-word characters

    Input P Hello -> P matches as it is adjacent to the start of the string and a space.

    In response to your comment below – If the first regex [..] is intended to find two full-stops/periods then this is not what it will do. [] denotes a character class and providing duplicate characters in a character class is meaningless. To match two full-stops use \.\.

    I’m not sure if combining into one regex is possible as the order of execution is very important…

    Hello..P..S is a P in isolation. However after removal of .. we have HelloPS which is not a P in isolation. To combine multiple replace is easy but they will all effectively happen ‘at the same time’ whereas your current method is doing one, then the next, then the next. ie – The input is different on each occasion.

    However to combine the replaces you would do…

     string cleanData = 
     Regex.Replace(DisplayText, @"(\.\.|\bPÑ?\b| )", ""); //untested :)
    

    Sort of demo

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

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.