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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:04:45+00:00 2026-06-04T21:04:45+00:00

I figure out how to remove special non alphanumeric character in python using the

  • 0

I figure out how to remove special non alphanumeric character in python using the following function:

p_nonalphanum = re.compile('\W+')

def removeNonAlphaNum(string):
        m = p_nonalphanum.match(string)
        if m:
            string = string[m.end():]
        return string

I would like to keep some specials characters though such as ½, ¾ which i consider as number. How should i edit my regex?

e.g: from “• ½ cup flour” to “½ cup flour”

  • 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-04T21:04:47+00:00Added an answer on June 4, 2026 at 9:04 pm
    >>> def remove_unwanted(s):
    ...     '''• ½ cup flour -> ½ cup flour'''
    ...     allowed = '[\w½¾]+'
    ...     return ' '.join(re.findall(allowed, s))
    ... 
    >>> print remove_unwanted('• ½ cup flour ->')
    ½ cup flour
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created this example The remove function doesn't work, and I can't figure out
I cant figure out how to remove the following: page_item page-item-xxx xxx = a
I am trying to figure out how to remove everything between and including in
I used several different posts on this site to figure out how to remove
I'm trying to remove certain emoticons from a string, but I can't figure out
I'm trying to figure out how to remove options from a select box when
I am trying to figure out how to remove a class from a parent
i want to implement the following exhaustive match, but i can't figure out to
I can't seem to figure out any way to remove the "No file selected"
I am trying to figure out why my delegate function does not work, any

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.