我正在尝试检查电子邮件列表的有效性。有效的电子邮件格式为:
name.lastname@host.domain
我可以使用正则表达式或LIKE运算符找到有效的电子邮件。但是,我想了解是否有一种方法可以使用其他列(例如“名称”和“姓氏”)中的数据来避免由唯一名称引起的任何问题,这些唯一名称包括[A-正则表达式中的Za-z]。
我已经尝试过:
script3.py
这:
static void Job3(Args _args)
{
TaxCalculation taxCalculation;
LedgerJournalTrans ledgerJournalTrans;
TmpTaxWorkTrans tmpTaxWorkTrans;
TaxAmountCur taxAmountCur;
ledgerJournalTrans = LedgerJournalTrans::findRecId(5637293082, false); // Use your own journal line
// The reason we call the below stuff is `element.getShowTax()` and is called from `\Forms\LedgerJournalTransDaily\Designs\Design\[ActionPane:ActionPane]\[ActionPaneTab:ActionPaneTab]\[ButtonGroup:ButtonGroup]\MenuItemButton:TaxTransSource\Methods\clicked`
// This is from `\Classes\LedgerJournalEngine\getShowTax`
taxCalculation = LedgerJournalTrans::getTaxInstance(ledgerJournalTrans.JournalNum, ledgerJournalTrans.Voucher, ledgerJournalTrans.Invoice, true, null, false, ledgerJournalTrans.TransDate);
taxCalculation.sourceSingleLine(true, false);
// This is from `\Classes\TaxTmpWorkTransForm\initTax`
tmpTaxWorkTrans.setTmpData(taxCalculation.tmpTaxWorkTrans());
// This is the temporary table that is populated
while select tmpTaxWorkTrans
{
// This is from `\Classes\TaxTmpWorkTransForm\getSourceBaseAmountCur`
taxAmountCur = (tmpTaxWorkTrans.SourceTaxAmountCur * tmpTaxWorkTrans.taxChangeDisplaySign(null)); // I pass null because the map doesn't appear used...investigate?
// This just outputs some data
info(strFmt("%1: %2", tmpTaxWorkTrans.TaxCode, taxAmountCur));
}
}
它们似乎工作得很好,但是我想了解是否可以通过LIKE这样的运算符来使用其他列中的数据。我认为使用现有列中的数据将导致更有针对性和更可靠的查询。
例如:
SELECT name,
lastname,
email,
CASE
WHEN email ~ '[A-Za-z]*\.[A-Za-z]*\@[A-Za-z]*\.[A-Za-z]*' THEN true
ELSE false
END AS valid
FROM personlist
答案 0 :(得分:1)
您可以使用其他列来计算要验证的模式。例如:
select
name,
lastname,
email,
lower(email) like lower(name || '.' || lastname || '@xmail.com') as valid
from personlist