• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

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.

TOPICS
How to

Views

482

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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! 😉

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

Oh awesome! Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

LATEST

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 

\.[\u\l]{3}

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines