in reply to Parse for a Single bit

The character class is not the problem, it's that all lines have a variable name, equals, prime and either 0 or 1. But you want the line to end there; if you don't make that explicit, the regexp matches and the remainder of the line is ignored. So you have to use /(.*?)=\'[01]$/

Edit: as davido beat me to it: yes, (\w+) makes much more sense than (.*) as empty identifiers (or those of weird characters ... although I vaguely remember some HDLs can use petty uncommon chars in wire names, right?) are certainly an error.

Replies are listed 'Best First'.
Re^2: Parse for a Single bit
by davido (Cardinal) on Jan 27, 2012 at 22:41 UTC

    Kudos for knowing what HDL's are. To me they're High-Density Lipoprotein. :)

    The problem presented by the OP only showed single alpha-character identifiers, so I went with \w. If there's a larger set of permissible identifiers, he might use an explicit character class, and if the identifiers may be longer than a single character, he might specify a quantifier. Greediness shouldn't be an issue since I'm explicitly anchoring to the start of the line, and to ='.


    Dave