我正在尝试使用正则表达式从以下 Google Analytic 中提取 UA-123456-7。我想我太接近了,但我不确定这是否可能。
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-123456-7");
pageTracker._trackPageview();
</script>
这是我在www.regular-expressions.info运行时得到的结果
正则表达式:^[<>%\w_\/.:;()\+-=?"]*(.*?)[<>\w_.;()]*$
替换文字:$1
结果: gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));var pageTracker = _gat._getTracker("UA-140422-1"
有人可以阐明一下吗?提前致谢!