如何只用egrep返回部分行(How to return only part of a line with egrep)
我有一个程序返回这样的内容:
status: playing artURL: http://beta.grooveshark.com/static/amazonart/m3510922.jpg estimateDuration: 29400 calculatedDuration: 293000 albumName: This Is It position: 7291.065759637188 artistName: Michael Jackson trackNum: 13 vote: 0 albumID: 3510922 songName: Billie Jean artistID: 39 songID: 24684170
我期待从这一切中提取艺术家的名字和歌曲名称,我认为egrep会是一个很好的方式。 问题是我不知道如何只返回部分匹配行而不是整行。
egrep "artistName"
显然返回artistName: Michael Jackson
我只需要它回来
Michael Jackson
任何帮助,将不胜感激。 谢谢。
I have a program that returns something like this:
status: playing artURL: http://beta.grooveshark.com/static/amazonart/m3510922.jpg estimateDuration: 29400 calculatedDuration: 293000 albumName: This Is It position: 7291.065759637188 artistName: Michael Jackson trackNum: 13 vote: 0 albumID: 3510922 songName: Billie Jean artistID: 39 songID: 24684170
I'm looking to extract the artist name and the song name from all this and I figured egrep would be a nice way to do it. The problem is that I have no idea how to return only part of the matching line and not the whole line.
egrep "artistName"
obviously returnsartistName: Michael Jackson
I only need it to return
Michael Jackson
Any help would be appreciated. Thanks.
原文:https://stackoverflow.com/questions/3646682
最满意答案
您可以使用
display:table
属性如下:#height-container{ background:orange; display: table; vertical-align:top; } #left{ display: table-cell; width:200px; background:#CD5555; padding:20px; } #right{ width:600px; display: table-cell; }
勾选此http://jsfiddle.net/6rBAw/2/
但它的工作,直到IE8及以上
已更新
CSS
#left{ width:200px; background:#CD5555; } #right{ float:right; width:600px; } .clr{clear:both;}
HTML
<div id='right'></div> <div id='left'> <div class="clr"></div> </div>
You can use
display:table
property for this:#height-container{ background:orange; display: table; vertical-align:top; } #left{ display: table-cell; width:200px; background:#CD5555; padding:20px; } #right{ width:600px; display: table-cell; }
Check this http://jsfiddle.net/6rBAw/2/
But it's work till IE8 & above
UPDATED
CSS
#left{ width:200px; background:#CD5555; } #right{ float:right; width:600px; } .clr{clear:both;}
HTML
<div id='right'></div> <div id='left'> <div class="clr"></div> </div>
Check it http://jsfiddle.net/6rBAw/4/
相关问答
更多-
是否有一个CSS唯一的解决方案,使垂直网格中div的高度相等?(Is there a CSS only solution to make divs equal height in a vertical grid?)[2023-09-20]
您可以使用包装 flexbox - 在调整窗口大小时,了解子div包装时高度是如何自动调整的(由于align-items:stretch属性是默认值)。 * { box-sizing: border-box; } body { margin: 0; } .wrapper { display: flex; flex-flow: row wrap; } .wrapper > div { border: 1px solid red; }如何使用左列内的右列创建2个相等高度的列?(How can I create 2 equal height columns with the right column inside the left column?)[2023-09-16]
使用FlexBox! ( display:flex; ) .container { height:100px; } .left-column { display:flex; background-color:blue; } .right-column { background-color:red; width:50%; margin-left:auto; }我能够成功地获得您正在寻找的结果。 解决方案是我第一次看到的解决方案: http : //offshootinc.com/blog/2011/11/23/getting-100-column-height-with-css/ 。 唯一的问题是您需要知道哪个列是具有最多内容的列才能使其工作。 如果经常更改(即:动态内容),您可能需要求助于Javascript解决方案。 我已经发布了下面的代码,但你也可以在这里查看jsFiddle: http : //jsfiddle.net/mesPb/