Visual Studio append text to end of lines using find/replace with end line regular expression ($)

谁说我不能喝 提交于 2019-12-08 15:47:05

问题


I am trying to append some text (e.g. "Fish") to the end of every line in a file using Visual Studio or SQL Server Management Studio using the following settings in the find/replace dialog:

  • Find what: $
  • Replace with: Fish
  • Use Regular expressions: Checked

This mostly does the job, but for a handful of lines it not only appends "Fish" to the end of the line it also puts it at the beginning of the line. I can't discern any pattern to this behaviour it seems to be almost random, with the larger the file the more lines tending to go wrong.

A similar find/replace with ^ (to put text at the beginning of the line) works with no problem.

Anybody know why this is happening? And also, are there any better suggestions for achieving what I want to?


回答1:


I'm not sure why you're seeing that, but you might try something like:

Find: ^.*$ 
Replace: \0Fish



回答2:


This works in Visual Studio 2012 and 2015:

Find: \r 
Replace: Fish\r

Make sure you tick 'Use Regular Expressions' checkbox:



来源:https://stackoverflow.com/questions/14483012/visual-studio-append-text-to-end-of-lines-using-find-replace-with-end-line-regul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!