Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

What follows is a solution which requires the minimum knowledge of the format. It works with the two special cases. Sorry, I must be tired today.

while (<>) { chomp; while ( / (\w+) # An identifier. \s* = \s* # Equal with opt spaces. ( (?: (?! \s+ \w+ \s* = ) # Stop if we see the next formula. . # A chararacter. )+ ) /xg ) { my ($name, $expr) = ($1, $2); $expr = substr($expr, 1, -1) if substr($expr, 0, 1) eq "'"; print("var: $name, expr: $expr\n"); } }

Output:

var: drsubc, expr: agauss(0, 1, 3) <- Works var: delm1, expr: 0 + 0.045u*distm1 var: delm2, expr: 0 + 0.07u*distm2 var: delm3, expr: 0 + 0.07u*distm3 var: delm4, expr: 0 + 0.07u*distm4 var: delmt, expr: 0 + 0.07u*distmt var: delml, expr: 0.16u + 0.43u*distml var: delam, expr: 0.32u + 0.86u*distam var: dele1, expr: 0 + 0.25u*diste1 var: dele2, expr: 0 + 0.25u*diste2 var: delma, expr: 0.16u + 0.6u*distma var: pmsxt, expr: npmsxt + 12.5u*dpmsxt var: tih, expr: 0.35u <- Works var: capct, expr: 0.50u + 0.13u*xdcapct var: capcti, expr: 0.55u + 0.13u*xdcapct var: m1t, expr: 0.41u + 0.05u*xdm1t var: m1ti, expr: 0.36u + 0.05u*xdm1t var: m2t, expr: 0.48u + 0.057u*dm2t var: m3t, expr: 0.48u + 0.057u*dm3t var: m4t, expr: 0.48u + 0.057u*dm4t var: mtt, expr: 0.48u + 0.057u*dmtt var: qtt, expr: 0.242u + 0.0202u*dqtt var: htt, expr: 0.242u + 0.0202u*dhtt var: mlt, expr: 2.0u + 0.2u*dmlt var: amt, expr: 4.0u + 0.4u*damt var: e1t, expr: 3.0u + 0.5u*de1t var: e2t, expr: 4.0u + 0.5u*xde1mat var: mat, expr: 4.0u + 0.4u*dmat var: m1m2t, expr: 0.35u + 0.05u*dm1m2t

In reply to Re^3: how to find what's not there with a regex? by ikegami
in thread how to find what's not there with a regex? by samizdat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-28 07:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found