简体   繁体   中英

regular expression to match everything between two words

Writing a TCL script to match everything in between two key words

Example:

X509v3 Extended Key Usage:

1.2.3.4, 1.3.6.1.4.1.311.4, 1.1.1.1, 234.432.1.36.4564.345

55.55.55.55, 66.66.66.66, 1234.5443.123.321.12.332.231.1

X509v3 Subject Key Identifier:

I want to be able to get all the information in between Extended Key Usage and Subject Key Identifier.

1.2.3.4, 1.3.6.1.4.1.311.4, 1.1.1.1, 234.432.1.36.4564.345

55.55.55.55, 66.66.66.66, 1234.5443.123.321.12.332.231.1

What I have tried without success:

set content [regexp {(?=<Extended Key Usage)(?s)(.*)(?=X509)} $ext match]
.
set content [regexp {\y(Extended Key Usage)(.*)(X509)\y} $ext match]
regexp -linestop {Extended Key Usage:\s.*[\r\n]+((?:.|[\r\n])*?)(?=\s*X509v3 Subject Key Identifier:)} $subject regexmatch result

Try this. The result is captured in capturing group 1. Lookbehind is not supported in TCL ARE http://wiki.tcl.tk/461

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM