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

  • Home
  • SEARCH
  • 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 911433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:12:20+00:00 2026-05-15T17:12:20+00:00

This seems like such a basic question, so I apologize if it’s already been

  • 0

This seems like such a basic question, so I apologize if it’s already been answered somewhere (my searching didn’t turn up anything).

I just want to filter a string object so that it contains only alphanumeric and space characters.

Here’s what I tried:

#include "boost/algorithm/string/erase.hpp"
#include "boost/algorithm/string/classification.hpp"

std::wstring oldStr = "Bla=bla =&*\nSampleSampleSample ";
std::wstring newStr = boost::erase_all_copy(oldStr, !(boost::is_alnum() || 
                                                      boost::is_space()));

But the compiler is not at all happy with that — it seems that I can only put a string in the second argument of erase_all_copy and not this is_alnum() stuff.

Is there some obvious solution I’m missing here?

  • 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-15T17:12:21+00:00Added an answer on May 15, 2026 at 5:12 pm

    With the std algorithms and Boost.Bind:

    std::wstring s = ...
    std::wstring new_s;
    std::locale loc;
    std::remove_copy_if(s.begin(), s.end(), std::back_inserter(new_s), 
        !(boost::bind(&std::isalnum<wchar_t>, _1, loc)||
          boost::bind(&std::isspace<wchar_t>, _1, loc)
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're right. The JSF 2 flash scope is currently extremly… May 16, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer "15:40:32.81".gsub(/:|\./, "") May 16, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer You may consider cropping your images into smaller tiles and… May 16, 2026 at 10:29 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This seems like such a simple question, but I'm having such difficulty with it.
What is the simplest way to parse line continuation characters? This seems like such
I apologize ahead of time if I am not asking this properly.. it is
This question is a result of a lunch-time conversation with a co-worker...I've read questions
It seems like the elevation of privileges is a common thing most developers fight
I'm fairly certain I know the answer to this, but any ideas would be
I'm creating a Brainfuck parser (in a BASIC dialect) ultimately to create an interpreter
I'm testing some legacy code that extends the default php exception object. This code
I'm recently working on this platform for which a legacy codebase issues a large
I have a program that downloads basic historical stock data from yahoo and puts

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.