假设我有一个包含内容的文件
SQL> SELECT 'conn '||u.name ||'/abcd123'||chr(10) ||'create '||DECODE(U.NAME,'PUBLIC','public ')||'database link ' || L.NAME|| ' connect to ' || L.USERID || ' identified by values '''||
2 L.PASSWORDX||''' using ''' || L.host || ''''||';' FROM system.xpr_link$ L, system.xpr_user$ U WHERE L.OWNER# = U.USER# and u.name not in ('APPS','SYS','SYSTEM') order by l.OWNER#;
conn GESADM/abcd123
create database link ODSPUSH.CISCO.COM connect to XXDM identified by values '056D98F3367CAC4478383FFB673E4D22329E172F2B25778BE3' using 'TS3ODS';
conn GESADM/abcd123
create database link TS3CFN.CISCO.COM connect to GESADM identified by values '05A0E92F39E91BA002F98DE9A46FC72B31572483E12D3AAB67' using 'TS3CFN';
create database link SYNSTG.CISCO.COM connect to SYN_CLNTSRV identified by values '066C10B37E3A3D0A3AA96B9FDE063585B662E3921F3C3F5A3E224BD4394A7BD659DAD174ABDE36594E7F3B466D6B0DCF78F13D75BA3B47090D295
8F8604E637462A2A41F74458E0C0EB649EE9A537AD2AE109A20B2DA09E5F9A28D666B8980651B79C0E76BBD6CBBCD169645970FDD615291C8557DBC79F527BF32E14A845025' using 'SYNSTG';
如何获得单词"值"在Perl中使用正则表达式。
答案 0 :(得分:0)
示例字符串中的每个位置" values
"发生时,它前面的单词(作为您在编辑之前请求的帖子)是" by
",所以我不知道它有多么有用捕获" values
"后面的每个单词。
尽管如此,这似乎是你要求的(在编辑之前颠倒了意义),这是一种方法:
while( $string =~ m/\b(\p{Alpha}+)\b\s*values/g ) {
print "$1\n";
}
...将产生以下输出:
by
by
by
by
另一方面,如果您打算在'值'""'" (类似于您编辑的帖子现在请求的),这将起作用:
while( $string =~ m/values\s*'([^']+)'/g ) {
print "$1\n";
}
......产生......
056D98F3367CAC4478383FFB673E4D22329E172F2B25778BE3
05A0E92F39E91BA002F98DE9A46FC72B31572483E12D3AAB67
066C10B37E3A3D0A3AA96B9FDE063585B662E3921F3C3F5A3E224BD4394A7BD659DAD174ABDE36594E7F3B466D6B0DCF78F13D75BA3B47090D295
8F8604E637462A2A41F74458E0C0EB649EE9A537AD2AE109A20B2DA09E5F9A28D666B8980651B79C0E76BBD6CBBCD169645970FDD615291C8557DBC79F527BF32E14A845025
答案 1 :(得分:0)