If I have two long lines, VARCHAR2s, there is a simple method or algorithm that I can copy or transfer to PL / SQL to compare them by inserting markup (i.e. so that differences are highlighted when rendering on a web page).
For instance:
BEGIN DBMS_OUTPUT.put_line( markup_differences (in_old => 'Hello world, this is your captain speaking.' ,in_new => 'Hello WORLD, this is not your captain.' ,in_preins => '<ins>' ,in_postins => '</ins>' ,in_predel => '<del>' ,in_postdel => '</del>' )); END;
Expected Result:
Hello <del>world</del><ins>WORLD</ins>, this is <ins>not</ins> your captain <del>speaking</del>.
Note that this indicates that the βworldβ was changed to βWORLDβ, that βnotβ was inserted, and that the βspeakerβ was deleted.
Background: My intention is to compare two basically similar snippets of HTML and mark them with highlights for display in the browser. Performance will not be a priority. This is for a one-time application, so I'm not after the perfect solution. Even if something hurts me, it will be better than nothing, and I have not promised anything to the client :)
Alternatively, a simple Javascript solution that I can easily incorporate into an Apex application might be acceptable.
source share