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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:56:05+00:00 2026-05-13T09:56:05+00:00

How can I match an alpha character with a regular expression. I want a

  • 0

How can I match an alpha character with a regular expression. I want a character that is in \w but is not in \d. I want it unicode compatible that’s why I cannot use [a-zA-Z].

  • 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-13T09:56:05+00:00Added an answer on May 13, 2026 at 9:56 am

    Your first two sentences contradict each other. “in \w but is not in \d” includes underscore. I’m assuming from your third sentence that you don’t want underscore.

    Using a Venn diagram on the back of an envelope helps. Let’s look at what we DON’T want:

    (1) characters that are not matched by \w (i.e. don’t want anything that’s not alpha, digits, or underscore) => \W
    (2) digits => \d
    (3) underscore => _

    So what we don’t want is anything in the character class [\W\d_] and consequently what we do want is anything in the character class [^\W\d_]

    Here’s a simple example (Python 2.6).

    >>> import re
    >>> rx = re.compile("[^\W\d_]+", re.UNICODE)
    >>> rx.findall(u"abc_def,k9")
    [u'abc', u'def', u'k']
    

    Further exploration reveals a few quirks of this approach:

    >>> import unicodedata as ucd
    >>> allsorts =u"\u0473\u0660\u06c9\u24e8\u4e0a\u3020\u3021"
    >>> for x in allsorts:
    ...     print repr(x), ucd.category(x), ucd.name(x)
    ...
    u'\u0473' Ll CYRILLIC SMALL LETTER FITA
    u'\u0660' Nd ARABIC-INDIC DIGIT ZERO
    u'\u06c9' Lo ARABIC LETTER KIRGHIZ YU
    u'\u24e8' So CIRCLED LATIN SMALL LETTER Y
    u'\u4e0a' Lo CJK UNIFIED IDEOGRAPH-4E0A
    u'\u3020' So POSTAL MARK FACE
    u'\u3021' Nl HANGZHOU NUMERAL ONE
    >>> rx.findall(allsorts)
    [u'\u0473', u'\u06c9', u'\u4e0a', u'\u3021']
    

    U+3021 (HANGZHOU NUMERAL ONE) is treated as numeric (hence it matches \w) but it appears that Python interprets “digit” to mean “decimal digit” (category Nd) so it doesn’t match \d

    U+2438 (CIRCLED LATIN SMALL LETTER Y) doesn’t match \w

    All CJK ideographs are classed as “letters” and thus match \w

    Whether any of the above 3 points are a concern or not, that approach is the best you will get out of the re module as currently released. Syntax like \p{letter} is in the future.

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

Sidebar

Related Questions

How can I use the startswith function to match any alpha character [a-zA-Z]. For
How can I match a field in the MySql-Database with a regular expression that
How can I build a regular expression in python which can match all the
How can I match a pattern in regex that can contain anything (letters,numbers,...) but
How can i match the following dates with python regular expression in one statement,
let me know I can use that expression to extract the url in the
I know i can match numbers with Pattern.compile(\\d*); But it doesn't handle the long
I have the following criteria for creating a regular expression for a password that
Can someone write a RegEx that can match : only lowercase URLs that can
The above regular expression (in Java) matches a string of alpha numeric characters of

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.