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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:44:05+00:00 2026-06-07T11:44:05+00:00

A string containing the relevant data is sent from a subprocess via the Popen

  • 0

A string containing the relevant data is sent from a subprocess via the Popen function and stdout.

 run = subprocess.Popen('evo -x "' + folder+filename+'"', stdout = subprocess.PIPE, stderr = subprocess.PIPE, env={'LANG':'C++'})
 data, error = run.communicate()

The string that prints the relevant information looks like this:

printf "height= %.15f \ntilt = %.15f (%.15f)\ncen_volume= %.15f\nr_volume= %.15f\n", height, abs(sin(tilt*pi/180)*ring_OR), abs(tilt), c_vol, r_vol;

and yields to the console on print data (with some extra stuff that is also in stdout):

Evolver 2.40, May 8, 2072; Windows OpenGL, 32-bit

Converting to all named quantities...Done.
Enter command: QUIET
height=    0.000211813357854 
tilt=0.0 (0.0)
cen_volume= 0.000000000600000
r_volume= 0.000000003000000
bad

I match it with:

dat = re.match("[\s]*height\s*=\s*([-]?[\.\d]*)[\s]*tilt\s*=\s*([-]?[\.\d]*)[\s]*\(([\s]*[-]?[\.\d]*)\)[\s]*cen_volume\s*=\s*([-]?[\.\d]*)[\s]*r_volume\s*=\s*([-]?[\.\d]*)[\s]*", data)

However, this is returning ‘None’. This exact same .match is used in programs that match the exact same information after it is read in from a txt file instead of stdout, and works perfectly in that case. Is there something unusual about the way that the string is treated, or some unusual extra non-visible character that is added, when this is retrieved via communicate? Note that .findall works perfectly fine for matching re.findall("[\s]*(bad)[\s]*", data), but even trying to match just a single line with .match still fails.

  • 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-07T11:44:07+00:00Added an answer on June 7, 2026 at 11:44 am

    two problems:

    1. use re.search as re.match would require the string to match from the first char
    2. add re.MULTILINE and re.DOTALL flags for the kind of multiline search you want

    Try:

    >>> re.search("[\s]*height\s*=\s*([-]?[\.\d]*)[\s]*tilt\s*=\s*([-]?[\.\d]*)[\s]*\(([\s]*[-]?[\.\d]*)\)[\s]*cen_volume\s*=\s*([-]?[\.\d]*)[\s]*r_volume\s*=\s*([-]?[\.\d]*)[\s]*", v,re.MULTILINE|re.DOTALL).groups()
    ('0.000211813357854', '0.0', '0.0', '0.000000000600000', '0.000000003000000')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string containing the following multi-line string value that I read from
I'd like to take data from a field which is a string of words
Given a string containing numbers and characters eg Mi2ch£al What would be the relevant
PHP has this wonderful function, strtotime , that takes any string containing just about
A time string containing minutes and/or seconds looks like this 29m 15s The delimiter
I have a string containing the variable name. I want to get the value
I have a string containing XML document using LinqtoXML What is the best way
I have this string containing a large chunk of html and am trying to
Given a text string containing a type name, is there some way to get
I have a string containing HTML and I need to replace some words to

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.