gmorissette
gmorissette

Reputation: 291

Regex \A until \r syntax

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).

Upvotes: 2

Views: 665

Answers (1)

Andie2302
Andie2302

Reputation: 4897

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.

Upvotes: 1

Related Questions