头都想破了 找不出解决的办法 求助
我想用bash脚本提取a.html文件里所有的name值 凡是在这里提取出的name值出现在b.html和d.html.....等等很多html文件里 那么就把出现在b.html和d.html,.....html中的name值替换掉 其中一个html文件内容如下:()
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="group_screens">Screens</string><string name="key_indicator_on">key_indicator_on</string><string name="donate_title">Donate</string>
<string name="indicator_on_title">Keep indicator on</string>
<string name="indicator_on_summary">Screen indicator always shown at the bottom</string>
<string name="key_default_screen">key_default_screen</string>
<string name="default_screen_title">Default screen</string>
<string name="default_screen_summary">The default screen Home++ will start with</string>
<string name="key_screen_number">key_screen_number</string><string name="cat_workspace">Workspace settings</string>
<string name="screen_number_title">Screen number</string>
<string name="screen_number_summary">The number of screens in your workspace</string>
<string name="cat_workspace">Workspace settings</string>
<string name="donate_summary">Offer your support</string>
<string name="donate_address">http://sites.google.com/site/launcherplus/donations</string>
<string name="hpp_ad_title">Try out Home plus plus</string>
<string name="hpp_ad_summary">Home++ is a</string>
<string name="starting_screen_switcher">Starting screen switcher</string>
</resources>
[解决办法]
你想取得所有html文件里 name的值?
用perl,不解释。
关键字 :模块 LWP::UserAgent 正则
正则举例:
while($html=~ /\<string name=(.*?)\>/gsi){
open (templist,'>>temp.txt');
print templist "$1\n";
close(templist);
}
templist是临时存放用的
正则可能写得不对。类似的格式自己去查。