regex - Match a line not ending in digit (with possible trailing white spaces) -


i want match line doesn't end in digit (with possibly trailing white spaces. using emacs regex (and open use other regex flavors).

  1. what regexs accomplish that?

  2. can use possessive quantifiers. (suppose possessive quantifiers work in emacs regex)

  3. here 2 attempt of mine.

    [^[:digit:]] *^j 

    where ^j new line character, typed c-q c-j, match

    concepts of logic 1 

    but

    [^[:digit:]] *$ 

    doesn't match

    concepts of logic 1 

    i wonder why there difference?

thanks.

so want match either line not end in char (i.e., empty) or line ends in character not digit , not newline char?

interactively, type regexp c-m-s, way:

\(^$\|[^c-qc-j[:digit:]]\)$ 

where typing c-q c-j inserts newline char (c-j) interactively. looks in isearch, ^j single (newline) char:

\(^$\|[^^j[:digit:]]\)$ 

from lisp, double backslashes , use \n represent newline char:

\\(^$\\|[^\n[:digit:]]\\)$ 

if want allow trailing whitespace, add [ \t]* before $. example, interatively:

\(^$\|[^c-qc-j[:digit:]]\)[ \t]*$ 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -