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).
what regexs accomplish that?
can use possessive quantifiers. (suppose possessive quantifiers work in emacs regex)
here 2 attempt of mine.
[^[:digit:]] *^j
where
^j
new line character, typedc-q c-j
, matchconcepts 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
Post a Comment