Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Does anyone know if in Gmail you can search all messages that have an exclamation mark in the subject?

I would like to create a filter that adds a red ! label to the messages that have an exclamation mark in the subject. But searching for subject:! results in all messages. I've tried things like /!/, /\!/, (/\!/), "!", but all these searches just give me all messages, not just those with ! in the subject.

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

From the "About Gmail Search" documentation:

Gmail doesn't recognize special search characters like square brackets, parentheses, currency symbols, the ampersand, the pound sign, and asterisks.

As you appear to have already discovered, and my quick tests appear to confirm, this seems to include the exclamation mark character.

I would assume that the regular expression Google are using to match search queries with possible results simply excludes all special characters and operates only on "word characters" (you can somewhat confirm this by the fact that searches for the underscore character, _, do work - the underscore is treated as a word character in a regular expression).

share|improve this answer
    
Thanks, not what I wanted to hear but at least I know I'll have to figure out something else for my needs. –  jankeir Sep 20 '12 at 8:09
    
What about the dash "-"? –  Pacerier Apr 25 at 9:30
add comment

With the help of Google Apps Script, you can use regular expressions in Gmail to find messages that have the exclamation mark in the subject.

The same script can be extended to apply Gmail filters to messages that match the expression.

Update: Here's the snippet of Apps Script that should help you find the relevant messages:

var pattern = "^!";
var threads = GmailApp.search("in:inbox");

for (var i = 0; i < threads.length; i++) { 
  var messages = threads[i].getMessages();

  for (var m = 0; m < messages.length; m++) {
      var subject = messages[m].getSubject();
      if (subject.search(pattern) !== -1) 
         Logger.log("https://mail.google.com/mail/u/0/#all/" + messages[m].getId());
  }
}
share|improve this answer
    
Please write the solution in the answer instead of just linking to your blog. –  Alex Sep 24 '12 at 18:14
    
Thanks Amit, good suggestion, although I fear that using it will make me run in to the apps script quota's even more than I already do. –  jankeir Sep 25 '12 at 10:20
    
True. Can't think of any other workaround though at this time. –  Amit Agarwal Sep 25 '12 at 11:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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