[OS X TeX] line breaks \n vs. \r ???
Jerome Laurens
Jerome.Laurens at u-bourgogne.fr
Tue Dec 18 11:02:15 EST 2007
Selon Steffen Wolfrum <mactex_aa at st.estfiles.de>:
> Hi,
>
> when editing in TextWrangler a line break is found when using Grep
> and search for \r.
> In TeXShop a line break is found when using Regular Expressions and
> searching for \n: \r gives no result!
>
Hi,
a tip to match line breaks using regular expressions, ignoring mac, windows or
unix end of line markers
1 you must choose the proper options:
- for perl compatible regular expression (a standard), 'multiline' and 'dot mach
all'
- for Ogre (the one in TS), uncheck 'single line' and check 'multiline'
2 use the proper regular expression: "$." will match a line break, either '\r',
'\n' or '\r\n'
Notice that one '.' after a '$' will match one line break, regardless the real
length (one for \r and \n, 2 for \r\n).
Depending on the situation, "$.?" is better in the sense that it also matches at
the end of the document
With the default options, '$' will only match at the end of the text. The
multiline option (in perl sense) allows '$' to match at the end of each line.
With the default options, '.' does not match end of line marks. The 'dot match
all' option (according to perl) allows '.' to match any end of line mark,
including unicode ones I guess.
Example: "(?<=$.)." will find the first character following a line break, it is
similar to "^." except that it does not match the first character of the text
So, if you are looking for line breaks, you do not need to worry about the
control characters actually in use in your text document, whether it is unix,
mac or windows.
More information about the MacOSX-TeX
mailing list