2

How could I write "Get everything from beginning of string (\A) until carriage return character (\r)" and leave rest as is in regex? I would like to use this in InDesign's GREP feature to style the first paragraph of a text box (before a carriage return).

Cyrus
  • 84,225
  • 14
  • 89
  • 153
gmorissette
  • 291
  • 1
  • 3
  • 13

1 Answers1

1

To search from the beginning of an string to a defined character:

Here the defined character is: \r and it is not included in the match.
Replace \r with the character you want.

\A[^\r]+

Here the defined character is: \r and it is included in the match.
Replace both \r with the character you want.

\A[^\r]+\r

To understand the regexes:

  • \A Assert the position at the beginning of the string.

  • [^\r]+ Match every character that is not a carriage return character between one and unlimited times.

  • \r Match the carriage return character.
Andie2302
  • 4,825
  • 4
  • 24
  • 43