算法学习正则防爆pression模式正则、算法、模式、pression

2023-09-05 04:28:06 作者:南城清梦

好了...所以这可能是一个延伸。 我想喂TextStrings的List功能和 那么它会返回常规EX pression语法回到我的身边。 我正与标签或标签的项目模式进行跟踪。 我想,以便能够检测所有存在的可能的模式。 我想一个普通的前pression,可以概括起来将是巨大的。

Okay... so this may be a stretch. I'd like to feed a List of TextStrings to a function and then it would return the regular expression syntax back to me. I'm working with a pattern of Tags or Tags for Items to be tracked. I'd like to to be able to detect all the possible patterns that exist. I thought a regular expression that could sum it up would be great.

这是不是已经做过。

我在VB.NET C#的建议工作的罚款。

I'm working in VB.NET C# suggestions are fine to.

也许这是一个糟糕的程序设计。但大多数想现在从哪里开始搜索? 唉,要是我在谷歌即使查找?

Maybe this is a poor programming design. But mostly wanted to now where to start searching? What would I even lookup under google?

或者你可以给我如何设计一个功能,像这样的一些方向?

Or can you offer me some direction on how to design a function like this?

推荐答案

很有趣的问题。不知道如果有一个很好的答案或没有,但,这是浮现在脑海的第一件事情:

Very interesting question. Not sure if there is a good answer or not but this was the first thing that came to mind:

Loop through each target string
    Loop through each character in each target string
       Categorize that character as precisely as possible.  7 = \d, f=[a-z] etc
       Create a list of the categories for each character in order.
       Add that list of categories to a list of lists
    End character loop
End target string loop

试图使用您的分类列表的列表来确定一个正则表达式匹配所有的目标字符串。例如,如果您的类别列表名单看起来是这样的:

Attempt to use your List of category lists to determine a regex that will match all target strings. For example if your List of Category Lists looks like this:

\d,\d,\d,[a-z],[a-z]
\d,\d,\d,[a-z],[a-z]
\d,\d,[a-z],[a-z]

您可能能够确定您的正则表达式匹配需要两到三个数字后面跟着两个小写字母。不是一大堆走下车的,但也许一个地方开始?我很想看看你想出了一个工作的解决方案...

You may be able to determine your regex needs match two to three digits followed by two lower case letters. Not a whole lot to go off of, but maybe a place to start? I'd be interested to see if you come up with a working solution...