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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:11:36+00:00 2026-05-25T15:11:36+00:00

So having such code that filters letters, and / .:= how to allow –

  • 0

So having such code that filters letters, and / ".:= how to allow -?

#include <boost/regex.hpp>
#include <boost/algorithm/string/regex.hpp>

std::string filter_args(std::string args)
{
    std::cout << boost::erase_all_regex_copy(args, boost::regex("[^a-zA-Z0-9=\"/.: ]+")); 
    return boost::erase_all_regex_copy(args, boost::regex("[^a-zA-Z0-9=\"/.: ]+"));
}
  • 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-25T15:11:36+00:00Added an answer on May 25, 2026 at 3:11 pm

    Boost’s default Regex behaviour is Perl-compatible, and man perlre says:

    You can specify a character class, by enclosing a list of characters
    in [], which will match any character from the list. If the first
    character after the “[” is “^”, the class matches any character not in
    the list. Within a list, the “-” character specifies a range, so that
    a-z represents all characters between “a” and “z”, inclusive. If you
    want either “-” or “]” itself to be a member of a class, put it at the
    start of the list
    (possibly after a “^”), or escape it with a
    backslash. “-” is also taken literally when it is at the end of the
    list, just before the closing “]”.
    (The following all specify the same
    class of three characters: [-az], [az-], and [a\-z]. All are
    different from [a-z], which specifies a class containing twenty-six
    characters, even on EBCDIC-based character sets.) Also, if you try to
    use the character classes \w, \W, \s, \S, \d, or \D as endpoints
    of a range, the “-” is understood literally.


    So:

    boost::erase_all_regex_copy(args, boost::regex("[^a-zA-Z0-9=\"/.: -]+"))
    

    or

    boost::erase_all_regex_copy(args, boost::regex("[^a-zA-Z0-9=\\-\"/.: ]+"))
    

    (notice the double-backslash; one to escape for the string literal, and the second to escape for the regex).

    I recommend the former.


    Always check out the documentation as your first port of call!

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

Sidebar

Related Questions

Seem to be having an issue with std::auto_ptr and assignment, such that the object
Below is a generalization of a block of code that I keep having to
Hey guys I'm having such a hard time of it today. I have a
Is there such a thing as having the most prefered design pattern for building
Having a problem getting a TreeView control to display node images. The code below
I having trouble with app that uses my static libs. Here is my setup:
I've got some heavily modified code that ultimately came from the Windows Media SDK
I am having a problem Scraping Code i require to extract information for a
I'm planning to release some compiled code that shall be linked by client applications
After having heard about new parts of the Perl ecosystem, such as Moose, DeclareX,

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.