昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期三, 四月 30, 2014

use xpath to extract web info in google chrome console



example:


var a = $x('//b[contains(., "人均")]/text()')
jQuery(a).text()
--
Feng

星期一, 四月 21, 2014

快速选择dropbox 的重复图片

因为把两个DROPBOX的 camera upload 文件合并了, 有不少重复的文件, dropbox 在重复的文件名后面加了 (1), 所以可以很容易看出重复的文件. 

但是有一百多个文件, 手工一个个找出来不容易, 于是写了段代码把不重复的文件隐藏起来.

在浏览器的命令行输入以下代码, 把正常的文件名藏起. 然后剩下的全是重复的, 就按住CONTROL键点选, 然后删除就可以了. 只是免了翻页寻找的过程. 并不能帮你选起.

注意, 不能用SHFIT键多选, 因为这样会选到藏起来的那些文件.

jQuery('.browse-file').each(
function(index, elem){
if (!/\(1\)/.test(jQuery(this).html())){
jQuery(this).hide();
}
}
);


--
Feng

星期三, 四月 09, 2014

YuFeng Deng's invitation is awaiting your response

 
YuFeng Deng would like to connect on LinkedIn. How would you like to respond?
YuFeng Deng
YuFeng Deng
Senior Software Developer @ MCom (Now Fiserv) - Doing Mobile, Web and Platform developments
Confirm you know YuFeng
You are receiving Reminder emails for pending invitations. Unsubscribe
© 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA

星期三, 四月 02, 2014

YuFeng Deng's invitation is awaiting your response

 
YuFeng Deng would like to connect on LinkedIn. How would you like to respond?
YuFeng Deng
YuFeng Deng
Senior Software Developer @ MCom (Now Fiserv) - Doing Mobile, Web and Platform developments
Confirm you know YuFeng
You are receiving Reminder emails for pending invitations. Unsubscribe
© 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA

星期二, 四月 01, 2014

regex, how look behind work

Look behind doesn't take space either

Look this example

(?m)(?<=a)bc.(?<=a)bc


it will only match abcabc

the matched string is bcabc


how to read this regex?

Remove the look behind first

it becomes bc.bc

OK, this will match quite a few string, like dbcebc


but, remember we have look behind, that means, before first bc, it must be an a, before second bc, it must be another a there. so....

only abcabc will match.


Look behind add another layer of restriction. easy?

--
Feng

Regex "And" operation

Regex "Or" operation is obvious.

This is a example

^abc$|^123$

This will match abc or 123. 

But how do you do a regex "and"

You may write something like this:

^abc$&^123$

Wrong, this is totally wrong. There is not "&" operator in regex.

Is it possible to do an "And" operation in regex? 

The answer is "YES".

That leads us to the power regex look around feature. 

For "And" operation, what we need is the positive look ahead.

(?m)^(?=.*[A-Z].*)(?=.*[a-z].*)(?=.*?[0-9].*)[^1]*$

Have a look example above. 

Look head matches, but doesn't take space, That means, the regex after the look ahead will start matching from the beginning as well.

In this example, the only matched string will be Abcd5234. 


Abcd1234
ABCD1234
abcd1234
abcdabcd
aBcd1234
aBcdabcd
Abcd5234


Why?

Because this string must match ^(?=.*[A-Z].*), means at least 1 Capital letter. 
Also, it must match (?=.*[a-z].*), one lowercase letter. 
Also, it must match (?=.*?[0-9].*), one number
and lastly, it must match [^1]*, no "1" included.





--
Feng

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.