Quantcast
Channel: Cadence Technology Forums
Viewing all articles
Browse latest Browse all 63627

Forum Post: RE: Help for Regular Expression, thanks in advance!

$
0
0
First of all, why do you want to use regular expression for this? The matching is limited to 9 captured parts. Your example contains 8 parts, so that should be ok. A parseString() also does the job. If you want to assign the fields to a variable then you better use destructuringBind(). some examples: str= "'F_X4'|'RA_PF'|'TYCO_2214762-5'|'ELASTO-GASKET_LITE-PIPES' ('!')='29-7810-01'|''|'(PFCON-80-ZSFP2X2-LP1X4-T22_IMPERIALXL,PFCON-80-ZSFP2X2-LP4X2-T22_PASSPORTXL)'|'1016'|'CON-80-SFP2PF-LP-T64':CDS_LW_PART_NUMBER='29-7810-01'" line = parseString(str "|") pp(line) pcre = pcreCompile("(.*)\\|(.*)\\|(.*)\\|(.*)\\|(.*)\\|(.*)\\|(.*)\\|(.*)") when(pcreMatchp(pcre str) f1 = pcreSubstitute(pcre "\\1") f2 = pcreSubstitute(pcre "\\2") f3 = pcreSubstitute(pcre "\\3") f4 = pcreSubstitute(pcre "\\4") f5 = pcreSubstitute(pcre "\\5") f6 = pcreSubstitute(pcre "\\6") f7 = pcreSubstitute(pcre "\\7") f8 = pcreSubstitute(pcre "\\8") line = list(f1 f2 f3 f4 f5 f6 f7 f8) pp(line) ) destructuringBind( (f1 f2 f3 f4 f5 f6 f7 f8 @rest junk) parseString(str "|") line = list(f1 f2 f3 f4 f5 f6 f7 f8) pp(line) ) Bram

Viewing all articles
Browse latest Browse all 63627

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>