Regex POSIX ERE(扩展正则表达式)中的正向查找或非捕获组
在CSV文件中,有与此类似的行:Regex POSIX ERE(扩展正则表达式)中的正向查找或非捕获组,regex,awk,regex-lookarounds,capturing-group,lookaround,Regex,Awk,Regex Lookarounds,Capturing Group,Lookaround,在CSV文件中,有与此类似的行: <iframe src="https://player.vimeo.com/video/30342373" width="640" height="364" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> 正在捕获:vimeo.com/video/30342373 如果我知道的没错,mawk只支持POSIX ERE语法,
<iframe src="https://player.vimeo.com/video/30342373" width="640" height="364" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
正在捕获:vimeo.com/video/30342373
如果我知道的没错,mawk
只支持POSIX ERE语法,这类似于egrep
如何仅从行中捕获唯一的视频id部分?使用
sed更容易:
str='<iframe src="https://player.vimeo.com/video/30342373" width="640" height="364" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'
sed 's~.*\.vimeo\.com/video/~~; s~" .*~~' <<< "$str"
30342373
str=''
sed的~.\.vimeo\.com/video/~;s~“*~”使用sed更容易:
str='<iframe src="https://player.vimeo.com/video/30342373" width="640" height="364" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'
sed 's~.*\.vimeo\.com/video/~~; s~" .*~~' <<< "$str"
30342373
str=''
sed的~.\.vimeo\.com/video/~;s~“*~”
$ awk '{gsub(/.*vimeo.com\/video\/|".*/,"")}1' file
30342373