开发者

Out of curiosity, how many people here know how regular expressions are compiled? [closed]

开发者 https://www.devze.com 2023-01-21 00:49 出处:网络
Closed. This q开发者_如何学Gouestion is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This q开发者_如何学Gouestion is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 12 years ago.

Improve this question

I'm going over this in my theory class, and I'm curious as to how many people here know what regular expression compilation actually is. I've looked online, and it seems to me that this is a more archaic topic that I thought it was.

So yeah, who here knew before reading this question that a regular expression compile is performed by converting the regex to an epsilon-nondeterministic finite automaton? Who has no clue what that is?


There's a very simple and elegant little regular expression compiler in C that Rob Pike wrote and Brian Kernighan describes in Chapter 1 of O'Reilly's Beautiful Code. It's pretty easy to learn from. Also compiler courses cover it: token types can be defined with regular expressions. So I imagine this knowledge isn't terribly rare.


Ok. I guess I'll be the first one to admit that, although I took a compiler's course a couple years ago and know the general principle of it, I think I would need to bring out the "Dragon Book" again and read up some more on the subject if I were actually asked to write the code that does this kind of thing.


I knew it had something to do with finite state machines, but nothing beyond that. Not really a subject I wanted to delve into... I suspect it's nasty under the hood. Not many people on SO seems how to use regular expressions at all, nevermind understand how they work.

0

精彩评论

暂无评论...
验证码 换一张
取 消