Skip to main content
smashkirk
Inspiring
September 30, 2016
Answered

GREP help

  • September 30, 2016
  • 3 replies
  • 917 views

Hi, this forum has been very helpful to me in the past, so I'm hoping someone could give me a hand again.

I'm looking for some GREP code to add a style to the date, and add a tab after the date:

Here is the copy:

Oct. 16 [tab] Chimo 5K & 10K, Fredericton, NB.

Nov. 2 [tab] Light Up the Lake, Saint John, NB.

Dec. 23 [tab] IGT Legs for Literacy, Moncton, NB.

So basically I want to select and change the first 6 or sometimes 7 characters (including a space), and add a tab after which I have written out as [tab].

I hope this makes sense. Any help is appreciated.

Thanks,

Ak

This topic has been closed for replies.
Correct answer chadb78135425

I just realized that my first answer does not let you apply a style to the date. Here is an updated code.

Find:"(^\u\l{1,4}\. \d{1,2}) "

Change to: "$1\t"

Chad

3 replies

chadb78135425Correct answer
Inspiring
September 30, 2016

I just realized that my first answer does not let you apply a style to the date. Here is an updated code.

Find:"(^\u\l{1,4}\. \d{1,2}) "

Change to: "$1\t"

Chad

smashkirk
smashkirkAuthor
Inspiring
September 30, 2016

Awesome, thanks Chad!

Obi-wan Kenobi
Legend
September 30, 2016

^((Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.?\h\d{1,2})\h

Don't forget "May" !

(^/)

Peter Kahrel
Community Expert
Community Expert
September 30, 2016

Find what: ^.+?\d+\K\s

Change to: \t

\K allows you to do variable-length lookbehinds. The Find what string says 'match the space following the first number in a paragraph'.

Peter

smashkirk
smashkirkAuthor
Inspiring
September 30, 2016

Thanks Peter, this is great. However, it seems to be adding a tab to every second line. Can I get it to do every line?

Inspiring
September 30, 2016

Try this, use all the code within the quotes.

Find: "(^\u\l{1,4}\.\s\d{1,2})\s(.+?$)"

Change to: "$1\t$2"

Chad

Peter Kahrel
Community Expert
Community Expert
September 30, 2016

Chad beat me to it by a whisker originally. . . Strange that the one I suggested with \K does every other paragraph instead of all. Not sure I understand that. But anyway, Chad provided the right solution!

Obi-wan Kenobi
Legend
September 30, 2016

Hi Peter,

Try this:  (?-s)^.+?\d+\K\s  or  (?s)^.+?\d+\K\s

(^/)

About Chad's answer, not really sure except if you want:

May. 21 ………