采用类似"This is, in text, an example! Cool stuff"
的输入
我有一些C#代码,它接受它,删除标点符号,拆分空格,并返回前6个元素:
var title = new string(input.Where(c => !char.IsPunctuation(c)).ToArray()).Split(' ').Take(6);
所以我得到一个数组:
["This", "is", "in", "text", "an", "example"]
从该数组中,我如何向后工作以将其与原始输入相匹配?我尝试过:'This|is|in|text|an|example'
,但它不够精确,因为我认为它正在进行或正在进行,而不是和。
我将在SQL查询中使用regex表达式,类似于:
SELECT t.*, Max(e.Timestamp) As EventUpdated, Min(e.Timestamp) as Timestamp
From test t
Left Join edithistory e on t.IdTimelineinfo = e.IdTimelineinfo
where t.date = "2020-12-06" and t.Title REGEXP 'Testing|two|events|on|the';
我真的是regex的新手,如果有任何帮助,我将不胜感激。
我最终使用了REGEX,如下所示:
DbTitle = string.Join("[^a-zA-Z]*", ArraryOfWords);
var title = $"[^a-zA-Z]*{DbTitle}";
SELECT t.*, Max(e.Timestamp) As EventUpdated, Min(e.Timestamp) as Timestamp
From test t
Left Join edithistory e on t.IdTimelineinfo = e.IdTimelineinfo
where t.date = @date and t.Title Regexp @title and Confirmed = 1;