Archive for the ‘Regular Expression’ Category
August 19, 2012 Leave a comment
Spending weekend with Regular expression.
Full regular expression conntain 2 types of characters. Special character that is Meta character (i.e *) , and the rest is literal (normal text characters).
This is the example of regular expression :
|^||caret||^cat||match a line with cat at beginning|
|$||dollar||dog$||match a line with dog at the end|
|[…]||character class||gr[ea]y||match with grey or gray|
|[^…]||Negated character class||gr[ea]y||[^1-6]match character that’s not in the range 1 through 6|
|–||dash||H[1-6]||same with H. it indicate range|
|(|)||Parentheses with bar||gr(a|e)y||Output is same with gr[a|e]y|
|¥<||backslash less-than||¥<cat¥>||match the position at the start of the word|
|¥>||backslash greater-than||¥<cat¥>||match the position at the end of the word|
|?||Question mark (means: optional)||colou?r||match color or colour. u part is always successful|
- Character class can only match a single character on the target