正则表达式/计算机理论 - 按字母顺序构建正则表达式 [英] RegEx / computer theory - construct a regEx in alphabetical order

查看:29
本文介绍了正则表达式/计算机理论 - 按字母顺序构建正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的语法 - 计算机理论课中,我试图按字母顺序(a-z)创建一个正则表达式

In my grammars - Computer theory class I am trying to create a regular expression in alphabetical order(a-z)

l = {a, b, x, y, z, i, o, u, e, c}

这是我想出的使用 kleene 闭包的方法

This is what i have come up with using the kleene closure

aeiou(x*, y*, z*, i*, o*, u* e*) 

当 kleene 接近 * 是零或更多,所以应该强制 abceioxyz?

With the kleene close * thats zero or more so that should force abceioxyz?

我们还没有学习过这种形式

We have not been learning this type of form

[^abc]

我在正确的轨道上吗?

推荐答案

据我所知,您希望捕获具有以下格式的字符串:

As far as I understand, you want to capture strings with the following format:

  • 字符串包含任意数量的a,然后是任意数量的b,然后是任意数量的c,等等...
  • The string contains any number of a's, afterwards any number of b's, then any number of c's, and so on...

让我们考虑一个派生的例子:我们想要所有由 01 组成的字符串,并且在 之前包含所有的 01的:因此,我们可以简单的写成0*1*.现在尝试为更复杂的字母调整模式.

Let's consider a derived example: We want all strings consisting of 0 and 1 and that has all 0's before 1's: Therefore, we can simply write 0*1*. Now try to adapt the pattern for more complex alphabets.

这篇关于正则表达式/计算机理论 - 按字母顺序构建正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆