Well, you could try something fancy, but first I'd make sure that a "dumb" approach isn't fast enough.
#!/usr/bin/perl -w use strict; my %fieldDescs=( 'ManagedSystem.Product', 'Product Code', 'ManagedSystem.Status', 'Status', # and many more, in actuality loaded from your database ); my %keywords=( EQ => 'is equal to', OFFLINE => "'OFFLINE'", IF => 'if', VALUE => 'the value of', # And your other keywords ); my $text="*IF *VALUE ManagedSystem.Product *EQ NT *AND *VALUE ManagedS +ystem.Status *EQ '*OFFLINE'"; # Substitute *FOO for the equivalent from %keywords, if it exists $text=~s/\*(\w+)\b/(exists $keywords{$1})?$keywords{$1}:$1/eg; # Substitute any word for its description from fieldDescs, if the word +s exists there $text=~s/\b([A-Za-z_\.0-9]+)\b/(exists $fieldDescs{$1})?$fieldDescs{$1 +}:$1/eg; print "New text is\n\t$text\n";
It's not algorithmically very advanced, and it will be somewhat slow, but it's mostly proportional to the number of words in your formulas, not the words in your Attribute names... It's worth a try.

Mike

In reply to Re: Search and Replace with a Large Dictionary by RMGir
in thread Search and Replace with a Large Dictionary by THuG

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.