Skip navigation
Chris Z.
Currently Being Moderated

Using the pipe in GREP

Jan 27, 2013 1:04 PM

Tags: #grep

Hi,

I'm trying to fashion a GREP search that finds an word in all caps, followed by a a space and then a word in U&lc or a digit. Then replace the space with a hard return.

 

Changing this:

TEXT DESIGN Marijka Kostiw

 

Into this:

TEXT DESIGN

Marijka Kostiw

 

However, sometimes I need to change something like this:

TEXT STOCK 150GSM MUNKEN PRINT CREAM

 

Into this:

TEXT STOCK

150GSM MUNKEN PRINT CREAM

 

This search/replace works if the initial uppercase word is followed by an U&lc word, but not if it is followed by a digit:

 

Find: (\u+) (\u\l)

Replace: $1\r$2

 

I'm having a tough time figuring out how to use the pipe to say "uppercase character followed by lowercase character or digit."

 

Can anyone offer any advice?

 

Thanks,

Chris

 
Replies
  • Currently Being Moderated
    Jan 27, 2013 1:40 PM   in reply to Chris Z.

    That would be

     

    (\u) (\u\l|\d)

     

    The pipe OR matches either the full left or the right expression; if the OR itself is inside a parenthesized group, only what's inside them is considered.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points