自动机与克莱尼明星 [英] Automata with kleene star

查看:133
本文介绍了自动机与克莱尼明星的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林学习自动机。能否请您帮助我了解如何自动机与克林截流工程?比方说,我有字母a,b,c和我需要找到与Kleene星结束文本 - 就像AB * BAC - 如何将它的工作

Im learning about automata. Can you please help me understand how automata with Kleene closure works? Let's say I have letters a,b,c and I need to find text that ends with Kleene star - like ab*bac - how will it work?

推荐答案

Kleene星号(*),是指只要你想(0或更多),你可以有性格的许多事件。 A * 将匹配任何数量的的。

The Kleene star('*') means you can have as many occurrences of the character as you want (0 or more). a* will match any number of a's.

(AB)* 将匹配任何数量的字符串AB

(ab)* will match any number of the string "ab"

如果你想匹配的前pression实际的星号,你会写的方式完全取决于您正在使用正则表达式的语法。对于一般的情况下,向下斜线 \ 被用作一个转义字符:

If you are trying to match an actual asterisk in an expression, the way you would write it depends entirely on the syntax of the regex you are working with. For the general case, the backwards slash \ is used as an escape character:

\ * 将匹配一个星号。

有关识别模式的尽头,使用串联:

For recognizing a pattern at the end, use concatenation:

(A U B)* C * 将匹配包含0个或更多的'C的底,通过任何数量的A或B的pceded $ P $任何字符串

(a U b)*c* will match any string that contains 0 or more 'c's at the end, preceded by any number of a's or b's.

有关匹配,与一个Kleene星结束的文字,同样,你可以0或多次出现的字符串:

For matching text that ends with a Kleene star, again, you can have 0 or more occurrences of the string:

AB(C)* - 可能的匹配:AB,ABC ABCC,abccc等

ab(c)* - Possible matches: ab, abc abcc, abccc, etc.

A(BC)* - 可能的匹配:一,农行,abcbc,abcbcbc等

a(bc)* - Possible matches: a, abc, abcbc, abcbcbc, etc.

这篇关于自动机与克莱尼明星的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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