Skip to main content
EmOlivette
Known Participant
January 18, 2021
Question

Writing a GREP to find any email with at least one uppercase letter

  • January 18, 2021
  • 1 reply
  • 1219 views

In my line of work, all emails must be lowercased. Typically an email is on a forced line break of its own. For example ^nem@emconsultinginc.com^n as such. Sometimes it has to be split due to columns such as: ^nem@em^nconsultinginc.com^n.

 

How do I write a grep that will look for next lines behind and ahead, with a string of text including: Upper Case, Lower Case, Numbers, Hyphens, Underscores, and potentially other next lines. But ONLY find those emails that include an uppercase letter. I wish to ignore the search finding emails that are completely lowercased.

This topic has been closed for replies.

1 reply

Brad @ Roaring Mouse
Community Expert
Community Expert
January 19, 2021

The last time I looked into this, there was no way in GREP to change case in the Find/Change dialog; it had be done with an external script. What you could do is do a search for all email strings and change them to a character style with a special color, which you could then search for subsequently, either for that character style or that color, then manually change case from the menu. Inelegant of course, but works. 

EmOlivette
Known Participant
January 19, 2021

I understand that I won't be able to change the case with GREP. The purpose of the GREP is to reduce the time required to search each email for any with an uppercase letter. So the function of my GREP is only to find the specific instances where an email has an uppercase letter "\u" within that string. I just don't know what my sequence needs to be to find all variants where the email may contain, upper, lower, numbers, hyphens and or underscores. In either the front half or back half of the @ sign. I do have a GREP to find Emails. But specifically I need to find an email with at least 1 uppercase letter so that my team can manually change the case -- again without searching through 1,000+ listings with 1 or more emails. Do you know how to do something like that?

Brad @ Roaring Mouse
Community Expert
Community Expert
January 20, 2021

I deleted part of my earlier response as I screwed up on my GREP.

In any case, what I would still do is a two-part search.

Search for ALL your emails as they are and change them to either a character style or special (temporary) color that you can search for later (e.g., create a spot colour EMAIL at 100%).

This GREP will find any emails with the possible characters you may have: lower and upper case, numbers, periods, hyphens, and also any forced line breaks you inserted:

 

\b[a-zA-Z0-9.-]+@[\na-zA-Z0-9.-]+\>

 

Search and Replace those with Found text ($0) and change to to the new character style or color.

Once that's done, do a second search for any uppercase character (\u) in that style or color.

 

Then you can delete the temporary color and style if you like.

There's probably a way to do make this simpler, but I can't think of it yet! 😉