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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:15:14+00:00 2026-06-15T02:15:14+00:00

I try to recognize the version of flexc++ program with regular expressions in CMake.

  • 0

I try to recognize the version of flexc++ program with regular expressions in CMake.

The ouput of flexc++ version is something like:

prompt$ flexc++ --version
flexc++ V1.01.00

I try to extract the version with regular expressions. The name of the executable is in a variable (and this variable is the output of other command). The problem is the string “++” in the flexc++ name. This string create a conflict with the symbol “+” (one or more matchs). A mini test:

set(sample "flexc++ V1.01.00")
set(flexname "flexc++")

string(REGEX REPLACE "^${flexname} V([0-9.]+)$" "\\1"
       output "${sample}")

message("${output}")

Throwing the next error:

RegularExpression::compile(): Nested *?+.
RegularExpression::compile(): Error in compile.
CMake Error at prueba.cmake:4 (string):
  string sub-command REGEX, mode REPLACE failed to compile regex "^flexc++
  V([0-9.]+)$".

If I erase the “++” string in sample and filename variables, it recognize perfect the version:

set(sample "flexc V1.01.00")
set(flexname "flexc")

string(REGEX REPLACE "^${flexname} V([0-9.]+)$" "\\1"
       output "${sample}")

message("${output}")

Output:

1.01.00

That means the problem is the “++” string.

How can I avoid this problem? For example, are there in CMake any command like:

scape(flexname_scaped ${flexname})

performing

flexname_scaped <-- flexc\\+\\+

?

How can I solve this problem?

  • 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-15T02:15:15+00:00Added an answer on June 15, 2026 at 2:15 am

    You can escape the "++" using string(REPLACE...):

    string(REPLACE "++" "\\+\\+" flexname_escaped ${flexname})
    string(REGEX REPLACE "^${flexname_escaped} V([0-9.]+)$" "\\1"
           output "${sample}")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

try: html = urlopen('http://glbse.com/api/asset/' + asset.name) except: print 'error while updating the price of
When I try to initialize the speech recognizer with the following code: SpeechRecognizer rec
Whenever i try to run sqlmetal, i get this: 'sqlmetal' is not recognized as
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
try { if (myBoolean) { while (true) ; } else { System.exit(1); } }
try: recursive_function() except RuntimeError e: # is this a max. recursion depth exceeded exception?
try { JSONArray jArray = new JSONArray(result); for(int i=0;i<jArray.length();i++) { JSONObject json_data = jArray.getJSONObject(i);
try { $friends = $facebook->api('/me/friends'); } catch (FacebookApiException $e) { error_log($e); } Shows :Fatal
Try executing the following in JavaScript: parseInt('01'); //equals 1 parseInt('02'); //equals 2 parseInt('03'); //equals

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.