title Regexp ref. author GPL(C) Mohsin Ahmed, http://www.cs.albany.edu/~mosh section REGEXP Emacs/Perl/Vim /* moshtag=regexp,vim,emacs { . Any char except newline, ? zero or one, * zero or more, + one or more, \+ in vim. \ quote, match next char literally, \Number of match of left open paren, [a-z] in char-class, [^a-z] not in char class, --------------------------------------------------------- Emacs Perl Vim --------------------------------------------------------- \| | | Alternative. \< \> \b \< \> Word begin/end. ^ $ ^ $ ^ $ Line begin/end. \` \' \A \Z Buffer begin/end. \sw \Sw \w \W \w \W Word char, not a word char. [0-9] \d \D \d \D Digit, not a digit. \s- \S- \s \S \s \S Space, not a space. [a-zA-Z] \a \A Alphabetic [a-z] \l \L Lower, not. [A-Z] \u \U Upper, not. + + \+ One or more. \{n,m} m..n (greedy). \( \) ( ) \( \) Grouping. \1 $1 \1 Group 1 that matched. \& $& & Whole match for re. ~ Last subst. :set magic :help regexp for non-eager. --------------------------------------------------------- Vim6 Regexp --------------------------------------------------------- \? 0 or 1 (greedy). \= 0 or 1 (greedy). \{n,m} \{-n,m} m..n (greedy,non-greedy). \{n} \{-n} n (greedy,non-greedy). \{,m} \{-,m} 0..m (greedy,non-greedy). * \{-} 0..more (greedy,non-greedy). \_. [.\n] \%^ \^# \%$ bof, cursor/point, eof. \%23l \%23c \23v line 23, column 23, vcolumn 23. \L \l \U \u \D \d alphabets (not)lower,(not)upper,(not)digit. \p printable. Directives \c \C \M \m \V \v (no)case,(no)magic,(no)very-magic-perl. --------------------------------------------------------- Emacs Syntax table. --------------------------------------------------------- \sC \SC In Class C, not in Class C. '\s ' or \s- whitespace, eg. [space,tab,newline,formfeed,..] (\S-) Not a space char. \sw (\Sw) word, eg. [a-zA-Z0-9]. (not a word char) \s_ (\S_) symbol, in C '_', in lisp `$&*+-_<>'. ' Not a symbol. \s. punctuation. \s( and \s) parenthesis eg. ()[]{}. \s" string quote, do not nest ". \s\ escape, eg. backslash. See words-include-escapes. \s/ character quote. \s$ paired delimiter, as in TeX. \s' expression prefix, eg 'x in elisp. \s< \s> comment start/end. \s@ inherit. \= Point Eg. for syntax class of backslash do: (char-to-string (char-syntax ?\\ )) To change the syntax class of _ to word: (modify-syntax-entry ?_ "w" ) --------------------------------------------------------- ksh patterns --------------------------------------------------------- ? Matches one file char except / and a . at the beginning of a file name. * Matches >= 0, same restrictions as ?. ?(pattern-list) Matches 0,1 of pattern-list. *(pattern-list) Matches zero or more of pattern-list. +(pattern-list) Matches >= 1, of pattern-list. @(pattern-list) Matches == 1, of pattern-list. !(pattern-list) Matches any string that does not match pattern-list. --------------------------------------------------------- MSDEV: VC++, MSDN isn't clear, please verify. --------------------------------------------------------- Usual: ^ | $ [a-z] [^] () \N . + \quotedchar OnlyVC: Usual notation { } \( \) # + @ * ..~X.. Not X X^N X{N,N} :a [a-zA-Z0-9] :c [a-zA-Z] :d [0-9] :h [0-9a-fA-F]+ :I [a-zA-Z_$][a-zA-Z0-9_$]* :n \d+.\d*|\d*.\d+|\d+ :q "[^"]*' | '[^']' :w [a-zA-Z]+ :z \d+ \t tab \x#### \u#### Unicode char in 4 hex numbers. --------------------------------------------------------- */ } ============================================================