Using Microsoft Word 2007, is it possible to replace the newline character (
\n) with some other character?
What about vice versa? (That is replace a character with the newline character).
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
According to this answer to a question on StackOverflow, Word versions '97-2013 used regular regexp syntax (pun intended). Unfortunately, it seems that Microsoft has since ditched regexp in favor of its own "Wildcard" syntax. I'm running Word 2016, and the only alternative to the basic literal searching (with a few special character escapes) is "Wildcard" matching, which is... basically an annoyingly limited regexp.
If you're using Word's version of regular expression (regex/regexp) syntax (enabled by checking the box labeled "Use wildcards" in the Find and Replace dialog*), then newlines are matched by
^13 (which I suppose is equivalent to
^p, "Paragraph mark", which Find/Replace only accepts when "Use wildcards" is not selected. Go figure!).
^l ("Manual line break"),
^n ("Column break"), will catch regular old newlines (like, the kind you enter when you press, well, the ENTER key.
I do believe that section breaks are matched by
m ("Page/Section break"), however.
NB: These Replace options are not accessible via the Find interface in the Navigation sidebar that pops up when you hit CTRL+F. As user3251498 has pointed out, you must hit CTRL + H to bring up the Find and Replace dialog.
So took me some time to figure this out.
Press ctrl + H keys together and you open a find and replace tab.
For searching a '\n' character or what enter key does you need to type
^l This makes it look for every place you have hit the enter key.
Also for some reason Microsoft word does not understand