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.#!/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";
In reply to Re: Search and Replace with a Large Dictionary
by RMGir
in thread Search and Replace with a Large Dictionary
by THuG
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |