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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:45:44+00:00 2026-05-24T11:45:44+00:00

I am trying to use this expression: Expression: \w{1,}\s*?\-\-(\>)?\s*?\w{1,} Keep in mind I am

  • 0

I am trying to use this expression:

Expression:  "\w{1,}\s*?\-\-(\>)?\s*?\w{1,}"

Keep in mind I am escaping the \ with a second \ in my code.

When searching in the strings below. I think I am close, but no cigar. I want the expression above to be able to find matches in the text below. Where am I going wrong?

Text:        "AB --> CD"
Text:        "AB --> Z"
Text:        "A --> 123d"
etc.

Resources Used:

  1. http://www.solarix.ru/for_developers/api/regex-en.html

  2. http://www.boost.org/doc/libs/1_47_0/libs/regex/doc/html/boost_regex/introduction_and_overview.html

  3. http://www.regular-expressions.info/reference.html


UPDATE

The comment helped me. I would still like to see people post on my thread, for record keeping purposes, regex sites that have helped them master regex. Anyways my code (mostly copied from the boost website) is.

/* All captures from a regular expression */
#include <boost/regex.hpp>
#include <iostream>

/* Compiled with g++ -o regex_tut -lboost_regex -Wall ./regex_tut.cpp */

void print_captures(const std::string& regx, const std::string& text)
{
   boost::regex e(regx);
   boost::smatch what;
   std::cout << "Expression:  \"" << regx << "\"\n";
   std::cout << "Text:        \"" << text << "\"\n";
   if(boost::regex_match(text, what, e, boost::match_extra))
   {
      unsigned i;
      std::cout << "** Match found **\n   Sub-Expressions:\n";
      for(i = 0; i < what.size(); ++i) {
         std::cout << "      $" << i << " = \"" << what[i] << "\"\n";
      }
   }
   else
   {
      std::cout << "** No Match found **\n";
   }
}

int main(int argc, char* argv[ ])
{
   print_captures("^\\w+\\s*-->?\\s*\\w+\\s*(\\(\\d+\\))?", "AB --> CD (12)" );
   return 0;
}

Seems to work. Please though so I can accept an answer post your favorite site up and give a newb a few pointers =).

  • 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-24T11:45:46+00:00Added an answer on May 24, 2026 at 11:45 am

    Not sure if i understood your question correctly, but if you want your regex to match for example AB and CD in "AB --> CD" you can use the following regex:

    Expression:  "(\w+)\s*-->?\s*(\w+)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use backslashes in raw strings with this regular expression: import re print
I'm trying to use this regular expression, but I'm having trouble testing it, because
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
I'm trying to use this layout with two 50% column width instead. But it
i am trying to use this code to bind my asp.net menu control to
I'm trying to use this code to replace spaces with _, it works for
i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now
I'm trying to use this expression. And It tell me that: storbinary() takes at
I'm trying use the Sum method in a lambda expression for a comparison, but
I am trying to use a regular expression like this: string Size= 10.5M; Match

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.