Search code examples
ultraedit

Ultraedit: How can i use clipboard content in FindRegexp macro?


In Ultraedit macros, the following works, and finds the content of the clipboard as expected:

Find "^c"

but the following does not:

Find RegExp "^c"

How can i use the contents of the clipboard in a Find RegExp macro?


Solution

  • Usage of ^c (clipboard content) and ^s (selected text) in search and replace explains briefly how to use ^c and ^s in a regular expression find/replace.

    ^s and ^c can be used only in non regular expression or in UltraEdit regular expression finds/replaces. When used in an UltraEdit regular expression find/replace, the selected text respectively contents of the clipboard is interpreted as UltraEdit regular expression string.

    Selected text and clipboard contents cannot be referenced within a Unix or Perl regular expression find/replace. There is no workaround solution for this limitation for UltraEdit macros.

    Such tasks are nowadays done with using an UltraEdit script instead of an UltraEdit macro as a script supports string variables and access of selected text and contents of clipboard. Therefore it is possible to build the search/replace string in an UltraEdit script first in a string variable and then run the regular expression find/replace with the value of the string variable.

    There are many examples of scripts using a dynamically modified search and/or replace string during script execution in the UltraEdit Scripts forum.