in reply to how to find what's not there with a regex?

Updated: Simplified.

#! perl -slw use strict; while( <DATA> ) { print "$1 : ", $2||$3 while m[ (\w+) ## the name \s+=\s+ ## the = (?: ## Either ' ( [^']+ ) ' ## all the non-quotes between quotes | ## or (.*?) ## the minimum ) \s{2,} ## absorb the two or more spaces ]gx; } =results P:\test>junk drsubc : agauss(0, 1, 3) delm1 : 0 + 0.045u*distm1 delm2 : 0 + 0.07u*distm2 delm3 : 0 + 0.07u*distm3 delm4 : 0 + 0.07u*distm4 delmt : 0 + 0.07u*distmt delml : 0.16u + 0.43u*distml delam : 0.32u + 0.86u*distam dele1 : 0 + 0.25u*diste1 dele2 : 0 + 0.25u*diste2 delma : 0.16u + 0.6u*distma pmsxt : npmsxt + 12.5u*dpmsxt tih : 0.35u capct : 0.50u + 0.13u*xdcapct capcti : 0.55u + 0.13u*xdcapct m1t : 0.41u + 0.05u*xdm1t m1ti : 0.36u + 0.05u*xdm1t m2t : 0.48u + 0.057u*dm2t m3t : 0.48u + 0.057u*dm3t m4t : 0.48u + 0.057u*dm4t mtt : 0.48u + 0.057u*dmtt qtt : 0.242u + 0.0202u*dqtt htt : 0.242u + 0.0202u*dhtt mlt : 2.0u + 0.2u*dmlt amt : 4.0u + 0.4u*damt e1t : 3.0u + 0.5u*de1t e2t : 4.0u + 0.5u*xde1mat mat : 4.0u + 0.4u*dmat m1m2t : 0.35u + 0.05u*dm1m2t =cut __DATA__ drsubc = agauss(0, 1, 3) delm1 = '0 + 0.045u*distm1' + delm2 = '0 + 0.07u*distm2' delm3 = '0 + 0.07u*distm3' + delm4 = '0 + 0.07u*distm4' delmt = '0 + + 0.07u*distmt' delml = '0.16u + 0.43u*distml' + delam = '0.32u + 0.86u*distam' dele1 = '0 + 0.2 +5u*diste1' dele2 = '0 + 0.25u*diste2' + delma = '0.16u + 0.6u*distma' pmsxt = 'npmsxt + 12.5 +u*dpmsxt' tih = 0.35u capct = '0.50u + + 0.13u*xdcapct' capcti = '0.55u + 0.13u*xdcapct' + m1t = '0.41u + 0.05u*xdm1t' m1ti = '0.36u + 0.05u*xdm1t' + m2t = '0.48u + 0.057u*dm2t' m3t = '0.4 +8u + 0.057u*dm3t' m4t = '0.48u + 0.057u*dm4t' + mtt = '0.48u + 0.057u*dmtt' qtt = '0.242u + +0.0202u*dqtt' htt = '0.242u + 0.0202u*dhtt' m +lt = '2.0u + 0.2u*dmlt' amt = '4.0u + 0.4u*dam +t' e1t = '3.0u + 0.5u*de1t' e2t = ' +4.0u + 0.5u*xde1mat' mat = '4.0u + 0.4u*dmat' + m1m2t = '0.35u + 0.05u*dm1m2t'

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re^2: how to find what's not there with a regex?
by samizdat (Vicar) on Aug 24, 2005 at 14:16 UTC
    dnwrs = agauss('cnr_res/3',1,3)

    An even loonier case... thanks, all, for the help. I think I'm going to have to go back to the original multiline source and see if these are more identifiable there.

      Any other variations?

      #! perl -slw use strict; while( <DATA> ) { m[(\w+)\s+=\s+'?(.+)'?] and print "$1 : $2" for split /\s{2,}(?=\w+\s+=)/, $_; } __END__ P:\test>junk drsubc : agauss(0, 1, 3) delm1 : 0 + 0.045u*distm1' dnwrs : agauss('cnr_res/3',1,3) delm2 : 0 + 0.07u*distm2' delm3 : 0 + 0.07u*distm3' delm4 : 0 + 0.07u*distm4' delmt : 0 + 0.07u*distmt' delml : 0.16u + 0.43u*distml' delam : 0.32u + 0.86u*distam' dele1 : 0 + 0.25u*diste1' dele2 : 0 + 0.25u*diste2' delma : 0.16u + 0.6u*distma' pmsxt : npmsxt + 12.5u*dpmsxt' tih : 0.35u capct : 0.50u + 0.13u*xdcapct' capcti : 0.55u + 0.13u*xdcapct' m1t : 0.41u + 0.05u*xdm1t' m1ti : 0.36u + 0.05u*xdm1t' m2t : 0.48u + 0.057u*dm2t' m3t : 0.48u + 0.057u*dm3t' m4t : 0.48u + 0.057u*dm4t' mtt : 0.48u + 0.057u*dmtt' qtt : 0.242u + 0.0202u*dqtt' htt : 0.242u + 0.0202u*dhtt' mlt : 2.0u + 0.2u*dmlt' amt : 4.0u + 0.4u*damt' e1t : 3.0u + 0.5u*de1t' e2t : 4.0u + 0.5u*xde1mat' mat : 4.0u + 0.4u*dmat' m1m2t : 0.35u + 0.05u*dm1m2t'

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
        That's close enough. \w doesn't work, because the LHS might be a function spec as in foo(a,b), but you guys have helped me understand the options and alerted me to more. Thanks very much to all of you, and I will go study more now.