我从网页(http://www.opensolaris.org/os/community/on/flag-days/all/)中提取一些代码,如下所示,
<tr class="build">
<th colspan="0">Build 110</th>
</tr>
<tr class="arccase project flagday">
<td>Feb-25</td>
<td></td>
<td></td>
<td></td>
<td>
<a href="../pages/2009022501/">Flag Day and Heads Up: Power Aware Dispatcher and Deep C-States</a><br />
cpupm keyword mode extensions - <a href="/os/community/arc/caselog/2008/777/">PSARC/2008/777</a><br />
CPU Deep Idle Keyword - <a href="/os/community/arc/caselog/2008/663/">PSARC/2008/663</a><br />
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
并且它中有一些相对的url路径,现在我想用正则表达式搜索它并用绝对url路径替换它们.因为我知道urljoin可以做那样的替换工作,
>>> urljoin("http://www.opensolaris.org/os/community/on/flag-days/all/",
... "/os/community/arc/caselog/2008/777/")
'http://www.opensolaris.org/os/community/arc/caselog/2008/777/'
Run Code Online (Sandbox Code Playgroud)
现在我想知道如何使用正则表达式搜索它们,最后将代码转换为,
<tr class="build">
<th colspan="0">Build 110</th>
</tr>
<tr class="arccase project flagday">
<td>Feb-25</td>
<td></td>
<td></td>
<td></td>
<td>
<a href="http://www.opensolaris.org/os/community/on/flag-days/all//pages/2009022501/">Flag Day and Heads Up: Power Aware Dispatcher …Run Code Online (Sandbox Code Playgroud) 我知道cout和printf今天有缓冲区,据说缓冲区有点像堆栈,从右到左得到cout和printf的输出,然后从顶部到bottem将它们(到控制台或文件)放出.像这样,
a = 1; b = 2; c = 3;
cout<<a<<b<<c<<endl;
buffer?|3|2|1|<- (take “<-” as a poniter)
output?|3|2|<- (output 1)
|3|<- (output 2)
|<- (output 3)
Run Code Online (Sandbox Code Playgroud)
然后我写下面的代码,
#include <iostream>
using namespace std;
int c = 6;
int f()
{
c+=1;
return c;
}
int main()
{
int i = 0;
cout <<"i="<<i<<" i++="<<i++<<" i--="<<i--<<endl;
i = 0;
printf("i=%d i++=%d i--=%d\n" , i , i++ ,i-- );
cout<<f()<<" "<<f()<<" "<<f()<<endl;
c = 6;
printf("%d %d %d\n" , f() , f() ,f() …Run Code Online (Sandbox Code Playgroud) 我知道cout几天前有缓冲区,当我google它时,据说缓冲区有点像堆栈并从右到左获取cout和printf的输出,然后将它们输出(到控制台或文件) )从顶部到bottem.像这样,
a = 1; b = 2; c = 3;
cout<<a<<b<<c<<endl;
buffer?|3|2|1|<- (take “<-” as a poniter)
output?|3|2|<- (output 1)
|3|<- (output 2)
|<- (output 3)
Run Code Online (Sandbox Code Playgroud)
然后我写下面的代码,
#include <iostream>
using namespace std;
int c = 6;
int f()
{
c+=1;
return c;
}
int main()
{
int i = 0;
cout <<"i="<<i<<" i++="<<i++<<" i--="<<i--<<endl;
i = 0;
printf("i=%d i++=%d i--=%d\n" , i , i++ ,i-- );
cout<<f()<<" "<<f()<<" "<<f()<<endl;
c = 6;
printf("%d %d %d\n" , f() , f() …Run Code Online (Sandbox Code Playgroud)