a= <<EOF
Password
:
7UV1ceFQ (You will be asked to change this after logging in for the first time)
EOF
,以获取密码。我需要提取值“7UV1ceFQ”使用正则表达式,我已经尝试使用“/密码:7UV1ceFQ /但它不工作,我想这是因为下一行字符包括,任何人都可以请建议我确切的这个值?需要使用正则表达式
a= <<EOF
Password
:
7UV1ceFQ (You will be asked to change this after logging in for the first time)
EOF
,以获取密码。我需要提取值“7UV1ceFQ”使用正则表达式,我已经尝试使用“/密码:7UV1ceFQ /但它不工作,我想这是因为下一行字符包括,任何人都可以请建议我确切的这个值?需要使用正则表达式
▶ a[/^\S+(?=\s\(You will be)/]
#⇒ "7UV1ceFQ"
上述正则表达式读作:
^
\S+
(?=\s\(You will be)
我不明白为什么我的问题不清楚,我我说的是“7UV1ceFQ”的值必须被提取。 – Gopal