test "one" hi
this is test "two" check
I need to "three" this


test "one" hi
this is test "Two" check
I need to "three" this

Is it possible to check that text (some function) in quotes (one, two, three) are lowercase text ? In example1 this function return true , but in example2 this function return false;

  • 3
    What have you tried?
    – phils
    Commented May 19, 2019 at 14:13
  • @phils function that return true if all text in quotes print in lowercase. Else return false. Smt like this. Commented May 19, 2019 at 15:04
  • 1
    Check where? Check how (interactively, by program)? What action do you mean by "check" (return a Boolean? do something else?) The question is unclear.
    – Drew
    Commented May 19, 2019 at 15:10
  • @Drew I updated my post Commented May 20, 2019 at 7:05
  • 1
    What have you tried so far to answer your own question? What’s not working yet?
    – Dan
    Commented May 20, 2019 at 18:00

2 Answers 2


If you use regular expressions as suggested by one of the other answers, you have to be careful to avoid checking text outside of quotes for uppercase letters. If you use just a single regular expression, you probably end up with the wrong result for

This is a "text" with some UPPERCASE letters outside the "quoted text"

You probably need to iterate through all the quoted text parts and check every one of them for an uppercase letter. For example:

(defun check-for-uppercase-in-quotes ()
 "Return t if quoted text containing uppercase letters is found"
    (goto-char (point-min))
    (let ((case-fold-search nil) (uppercasefound nil)) 
      (while (and (not uppercasefound) (re-search-forward "\"\\([\0-\377[:nonascii:]]*?\\)\"" nil t nil))
        (setq uppercasefound (string-match ".*[[:upper:]].*" (match-string 1))))

Edit: Modified the regular expression so that quoted text with multiple lines is correctly recognized.

  • 1
    Great! The one thing left to do is include \n to regexp to handle multiline quoted texts ;)
    – muffinmad
    Commented May 22, 2019 at 9:31
  • @muffinmad: Well spotted:) Fixed it now.
    – StarBug
    Commented May 22, 2019 at 10:37

For example, you can search upper-case letters in quotes.

(defun all-text-in-quotes-is-lowercase ()
  "Return t if text in quotes are lowercase text."
    (goto-char (point-min))
    (let ((case-fold-search nil))
      (not (search-forward-regexp "\".*[[:upper:]]+.*\"" nil t)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.