How to copy data inside an html/xml tag to clipboard?

How to copy data inside an html/xml tag to clipboard?

81
Advanced UserAdvanced User
81

    Feb 13, 2016#1

    I have a file containing the following

    Code: Select all

    <ce:doi>11.1254/a1.0000</ce:doi>
    <ce:doi>11.1254/a1.0040</ce:doi>
    <ce:doi>11.1254/a1.15x0</ce:doi>
    
    and other para or any other tags.

    What I want is to search for the string <ce:doi>...</ce:doi> and copy the data inside the tag e.x. the values "11.1254/a1.0000" so that I can find it on another file which has the values i.e. "11.1254/a1.0000", but inside a different tag like <doi>11.1254/a1.0000</doi>.

    Normally what I do is search "<ce:doi>^(*^)</ce:doi>" then copy the finding on another page and I have to replace both "<ce:doi>" and "</ce:doi>" then copy the remaining thing to find it on the document that has <doi>...</doi> format.

    Is there a short way to store the value inside the tag "<ce:doi>...</ce:doi>" to clipboard for immediate use in another file?

    6,603548
    Grand MasterGrand Master
    6,603548

      Feb 13, 2016#2

      You can get the strings within ce:doi tags listed line by line into a new file by running script FindStringsToNewFile.js on active file and entering as search expression <ce:doi>(.+?)</ce:doi> and $1 as replace expression as long as there are not 1 or more newline characters within start and end tags.

      But it is of course also possible to get each string within ce:doi tags separately selected in file by using a Perl regular expression find with a positive lookbehind and a positive lookahead. UltraEdit and Unix regular expression engines do not support lookbehind and lookahead and therefore can't be use for this task as easily as the Perl regexp engine.

      Perl regexp search string for <ce:doi> and </ce:doi> being always on same line: (?<=<ce:doi>).+?(?=</ce:doi>)

      Perl regexp search string for <ce:doi> and </ce:doi> can be also on different lines: (?<=<ce:doi>)[\s\S]+?(?=</ce:doi>)

      About groups in Perl regular expression:

      (...) ... marking (capturing) group for back-referencing string found by the expression inside in search or replace string by $1, $2, ..., $9 or \1, \2, ..., \9.

      (?:...) ... non marking group used for nesting groups, an OR expression, or applying a multiplier to an expression.

      The following groups do not match (select) characters. The expression inside the groups must define 1 or more (using an OR expression) strings of fixed length. Then can contain variable characters by using 1 or more positive [...] or negative [^...] character classes, but length of each string must be fixed. In other words multipliers like + or * are not possible in those groups, but multiplier ? (0 or 1) is supported.

      (?=...) ... a positive lookahead (= ... equal ahead) never matching (selecting) characters, just looking ahead and checking if there is a string matching the expression inside the lookahead group.

      (?!...) ... a negative lookahead (! ... not equal ahead) never matching (selecting) characters, just looking ahead and checking if there is not a string matching the expression inside the lookahead group.

      (?<=...) ... a positive lookbehind (<= ... equal behind).

      (?<!...) ... a negative lookbehind (<! ... not equal behind).

      It is possible to use multiple lookaheads or lookbehinds in sequence, for example (?=</ce:doi>)(?=</ce:dio>) which could be also coded as (?=</ce:d(?:oi|io)>).
      Best regards from an UC/UE/UES for Windows user from Austria

      81
      Advanced UserAdvanced User
      81

        Feb 13, 2016#3

        About using script, how can I write an UltraEdit script and save it using only UltraEdit or do I need another tool for that?

        6,603548
        Grand MasterGrand Master
        6,603548

          Feb 13, 2016#4

          UltraEdit scripts have usually the file extension .js like JavaScript files because being interpreted by JavaScript interpreter integrated in UltraEdit itself. All JavaScript standard built-in objects can be used also in UltraEdit scripts.

          But there are also some UltraEdit specific objects with their methods and properties as listed in help of UltraEdit on page Scripting commands. The usage of those commands is most easily done by opening View - Views/Lists - Tag List and selecting tag group UE/UES Script Commands. Double clicking on a command in this list inserts the command into active file at current caret position and sets the caret where to edit next. For some tags (commands) a currently selected string is taken into account on inserting the tag (variable name, search string, ...).

          If a file with file extension .js is active in UltraEdit, the menu Scripting contains the menu item Run Active Script. If the active *.js file is really an UltraEdit script not designed for running on active file, this command can be used to run the UltraEdit script. But most scripts are designed to run on active file and require therefore a different method for execution.

          UltraEdit scripts can be stored anywhere with read access for current user (and write access on developing). I suggest storing them in directory %APPDATA%\IDMComp\UltraEdit\scripts whereby the directory scripts must be first created once. This makes it easy possible to backup the scripts together with the other UltraEdit configuration files using Advanced - Backup/Restore User Customizations.

          To run a script on active file, it is necessary to click in menu Scripting on menu item Scripts and Add a script (already finished or just developing) to the list of scripts. It is possible to assign a hotkey or chord to a script for quick execution by key if the script is often needed. A description explaining briefly what the script is for can be also given.

          Once an UltraEdit script is added to the list, it can be executed on active file by clicking on it in menu Scripting or double clicking on it in Script List opened either via Scripting - Script List or View - Views/Lists - Script List. Of course the Script List can be docked on left or right side with or without auto-hide like all other lists. And visibility of this list can be also toggled by a click on appropriate icon in toolbar or using a hotkey/chord assigned to command ViewShowHideScriptList in Key Mapping configuration dialog.

          It is even possible to run UltraEdit with executing an UltraEdit script on one or more files from command line or from within a batch file. See in help of UltraEdit the page Command Line Parameters and read also Always get error message when running a macro/script via command line parameter when you plan to run UltraEdit from within a batch file with executing a macro or script on one or more files.
          Best regards from an UC/UE/UES for Windows user from Austria