How can I use a regular expression to match something in the form 'stuff=foo' 'stuff' = 'stuff' 'mor

Posted by PherricOxide on Stack Overflow See other posts from Stack Overflow or by PherricOxide
Published on 2010-05-27T02:19:00Z Indexed on 2010/05/27 2:31 UTC
Read the original article Hit count: 428

Filed under:

I need a regexp to match something like this,

'text' | 'text' | ... | 'text'(~text) = 'text' | 'text' | ... | 'text'

I just want to divide it up into two sections, the part on the left of the equals sign and the part on the right. Any of the 'text' entries can have "=" between the ' characters though. I was thinking of trying to match an even number of 's followed by a =, but I'm not sure how to match an even number of something.. Also note I don't know how many entries on either side there could be. A couple examples,

'51NL9637X33' | 'ISL6262ACRZ-T' | 'QFN'(~51NL9637X33) = '51NL9637X33' | 'ISL6262ACRZ-T' | 'INTERSIL' | 'QFN7SQ-HT1_P49' | '()'

Should extract, '51NL9637X33' | 'ISL6262ACRZ-T' | 'QFN'(~51NL9637X33) and, '51NL9637X33' | 'ISL6262ACRZ-T' | 'INTERSIL' | 'QFN7SQ-HT1_P49' | '()'

'227637' | 'SMTU2032_1' | 'SKT W/BAT'(~227637) = '227637' | 'SMTU2032_1' | 'RENATA' | 'SKT28_5X16_1-HT5_4_P2' | '()' :SPECIAL_A ='BAT_CR2032', PART_NUM_A='202649'

Should extract, '227637' | 'SMTU2032_1' | 'SKT W/BAT'(~227637) and, '227637' | 'SMTU2032_1' | 'RENATA' | 'SKT28_5X16_1-HT5_4_P2' | '()' :SPECIAL_A ='BAT_CR2032', PART_NUM_A='202649'

Also note the little tilda bit at the end of the first section is optional, so I can't just look for that.

© Stack Overflow or respective owner

Related posts about regex