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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:08:42+00:00 2026-05-14T17:08:42+00:00

I use this regex on some input, [^a-zA-Z0-9@#] However this ends up removing lots

  • 0

I use this regex on some input,

[^a-zA-Z0-9@#]

However this ends up removing lots of html special characters within the input, such as

#227;, #1606;, #1588; (i had to remove the & prefix so that it wouldn't 
show up as the actual value..)

is there a way that I can convert them to their values so that it will satisfy the regexp expression? I also have no idea why the text decided to be so big.

  • 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-14T17:08:42+00:00Added an answer on May 14, 2026 at 5:08 pm

    Given that your text appears to have numeric-coded, not named, entities, you can first convert your byte string that includes xml entity defs (ampersand, hash, digits, semicolon) to unicode:

    import re
    xed_re = re.compile(r'&#(\d+);')
    def usub(m): return unichr(int(m.group(1)))
    
    s = 'ã, ن, ش'
    u = xed_re.sub(usub, s)
    

    if your terminal emulator can display arbitrary unicode glyphs, a print u will then show

    ã, ن, ش
    

    In any case, you can now, if you wish, use your original RE and you won’t accidentally “catch” the entities, only ascii letters, digits, and the couple of punctuation characters you listed. (I’m not sure that’s what you really want — why not accented letters but just ascii ones, for example? — but, if it is what you want, it will work).

    If you do have named entities in addition to the numeric-coded ones, you can also apply the htmlentitydefs standard library module recommended in another answer (it only deals with named entities which map to Latin-1 code points, however).

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

Sidebar

Related Questions

I am getting some problems while trying to use this regex: (public +function|private +function|function)
I need to validate some textbox input. I want to use a regex. The
I have this HTML input: <font size=5><p>some text</p> <p> another text</p></font> I'd like to
I use this regex to put thousand separators in a string: while matchstr(mystr, '\(\d\)\(\d\{3}\)\(\D\|\s\|$\)')
I am trying to use this regex (JS): /\/\*(.*)\*\//g To replace /* sdandsads */
I have this data: /blabla/blabla (abs,def) /yxz I use this regex (.*)(?:\(([^$]*)\))?\n But it
I want to use this regular expression in Python: <(?:[^]*[']*|'[^']*'[']*|[^'>])+> (from RegEx match open
I don't know if I can use regex for this, but I want to
I want to use a variable in a regex, like this: variables = ['variableA','variableB']
I'm trying to use regex to parse some plain text and add a definition

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.