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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:21:49+00:00 2026-05-25T16:21:49+00:00

I need some help figuring out the regex for XML character references to control

  • 0

I need some help figuring out the regex for XML character references to control characters, in decimal or hex.

These sequences look like the following:

�





In other words, they are an ampersand, followed by a pound, followed by an optional ‘x’ to denote hexadecimal mode, followed by 1 to 4 decimal (or hexadecimal) digits, followed by a semicolon.

I’m specifically trying to identify those sequences where they contain (inclusive) numbers from decimal 0 to 31, or hexadecimal 0 to 1F.

Can anyone figure out the regex for this??

  • 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-25T16:21:50+00:00Added an answer on May 25, 2026 at 4:21 pm

    If you use a zero-width lookahead assertion to restrict the number of digits, you can write the rest of the pattern without worrying about the length restriction. Try this:

    &#(?=x?[0-9A-Fa-f]{1,4})0*([12]?\d|3[01]|x0*1?[0-9A-Fa-f]);
    

    Explanation:

    (?=x?[0-9A-Fa-f]{1,4})  #Restricts the numeric portion to at most four digits, including leading zeroes.
    0*                      #Consumes leading zeroes if there is no x.
    [12]?\d                 #Allows decimal numbers 0 - 29, inclusive.
    3[01]                   #Allows decimal 30 or 31.
    x0*1?[0-9A-Fa-f]        #Allows hexadecimal 0 - 1F, inclusive, regardless of case or leading zeroes.
    

    This pattern allows leading zeroes after the x, but the (?=x?[0-9A-Fa-f]{1,4}) part prevents them from occurring before an x.

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

Sidebar

Related Questions

Hey all, i am in need of some help with figuring out how to
I'm a n00b and I need some help figuring out this issue, I would
I need help figuring out some regular expressions. I'm running the dig command and
I need some help figuring out what I'm doing wrong here. I am trying
I need some help with figuring out Pythons *args and **kwargs . It's simple
I need some help figuring out a solution to a z-index problem with ie7.
I need some help figuring out the best way to proceed with creating a
I need some help figuring out and SQL Statement. I know what I want
I need some help figuring out this for loop logic. I know exactly what
I need some help figuring this out. I am trying to create a function

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.