In my line of work, all emails must be lowercased. Typically an email is on a forced line break of its own. For example ^email@example.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.
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.
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?
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:
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! 😉
Oh awesome! Thanks!
Acutally, I just realized, that when using this string, it is changing not only the email, but also the next word on the next line.
Is there a way to make the GREP end after a period and a string of 3 letters and a next line?
I tried adding
to the end of your string, but now it is picking up not only emails, but websites too.
Also, sometimes our company needs to nextline/tab in when the email is long. Is there a way to add that to this string? Or is this getting too vague for it to find anything?