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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:35:47+00:00 2026-05-13T15:35:47+00:00

My input consists of user-posted strings. What I want to do is create a

  • 0

My input consists of user-posted strings.

What I want to do is create a dictionary with words, and how often they’ve been used.
This means I want to parse a string, remove all garbage, and get a list of words as output.

For example, say the input is
"#@!@LOLOLOL YOU'VE BEEN \***PWN3D*** ! :') !!!1einszwei drei !"

The output I need is the list:

  • "LOLOLOL"
  • "YOU'VE"
  • "BEEN"
  • "PWN3D"
  • "einszwei"
  • "drei"

I’m no hero at regular expressions and have been Googling, but my Google-kungfu seams to be weak …

How would I go from input to the wanted output?

  • 1 1 Answer
  • 3 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-13T15:35:47+00:00Added an answer on May 13, 2026 at 3:35 pm

    Simple Regex:

    \w+

    This matches a string of “word” characters. That is almost what you want.

    This is slightly more accurate:

    \w(?<!\d)[\w'-]*

    It matches any number of word characters, ensuring that the first character was not a digit.

    Here are my matches:

    1 LOLOLOL
    2 YOU’VE
    3 BEEN
    4 PWN3D
    5 einszwei
    6 drei

    Now, that’s more like it.

    EDIT:
    The reason for the negative look-behind, is that some regex flavors support Unicode characters. Using [a-zA-Z] would miss quite a few “word” characters that are desirable. Allowing \w and disallowing \d includes all Unicode characters that would conceivably start a word in any block of text.

    EDIT 2:
    I have found a more concise way to get the effect of the negative lookbehind: Double negative character class with a single negative exclusion.

    [^\W\d][\w'-]*(?<=\w)

    This is the same as the above with the exception that it also ensures that the word ends with a word character. And, finally, there is:

    [^\W\d](\w|[-']{1,2}(?=\w))*

    Ensuring that there are no more than two non-word-characters in a row. Aka, It matches “word-up” but not “word–up”, which makes sense. If you want it to match “word–up”, but not “word—up”, you can change the 2 to a 3.

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

Sidebar

Related Questions

I have user input that consists of a drawn rectangle (freestyle). Now this drawn
In a C++ program I'm trying to process user input which consists of integer
So for this C# class I have to have the user input a 7
I am validating an input of the user registration form that consists of two
My input XML consists of the following, <root> <entry> <type>U</type> <value>111</value> </entry> <entry> <type>X</type>
How does one use boost::spirit with an input that consists of something other than
I have a simple HTML form which consists of radio buttons where user has
My application will basically accept user input via the main(String[] args) method. I have
I need to provide AutocompleteBox that will give user ability to input data. Completion
I want to build an string/text manipulation app that: An app consists of a

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.