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).
Asked
Active
Viewed 621 times
2
-
This question belongs on superuser.com – Josh Voigts Aug 13 '14 at 12:52
-
Ok sorry I'm new to stack communities – gmorissette Aug 13 '14 at 12:56
-
And just why would it belong there? – gmorissette Aug 13 '14 at 12:58
-
Stackoverflow is for programming questions related to code. Superuser is for general computing questions. It's an easy thing to mix up and sometimes the lines blur a little bit. InDesign javascripting questions, for example, could go on either site... – Josh Voigts Aug 13 '14 at 13:01
1 Answers
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