Hi, all. I think I'm in way over my head and could use your help.
I am trying to rewrite email alerts from one system so they can generate tickets in a different system. I thought I could get clever and create a template with field names that the program would fill in with values from the incoming email.When the program encounters a string of the form %-Field Name-% it replaces it with the field with that name in the incoming email. So far, so good.
The problem is that some of the fields need to be trimmed or reformatted. I thought I could add some syntax--hugely ugly, I know--that would let me specify s/// substitutions in the template file, so that %-Incoming Port%%/dev/pts/%%Port Number-% would be read as Print the value of the "Port Number" field, but replace the string "/dev/pts/" with "on Port# ". ALSO working just fine, thankyouverymuch.
Or so I thought until I tried to use () and \1 in the template, anyway. %-Message Text%%.* for (.*) from .*%%\1-% (so that "successful login for root from blah blah" gets rewritten as "root") fails emphatically, miserably, repeatedly, as do I.
I've lost count of the number of things I've tried, but I've been googling, reading, and putzing for about 8 hours now and I'd dearly love a hint. I feel like it must be possible because this much seems to work:
$val=$envalert{$var}; if ($val =~ /$modfrom/) { $replval = $1 ;
When $modfrom contains ()'s, then $1 seems to get set properly. But I can't wrap my head around how to do the rest of the substitution. Any pointers will be gratefully received.
In reply to Regex with variables by eshafto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |