What is '+' in regex?

Viewed 40

I'm not exactly sure whether or not this is a duplicate, but I sadly couldn't find the answer to my problem anywhere, so I decided to ask here.

Disclaimer: I'm very new to regex, so I apologize in advance if this question is dumb.

I have to study the conversion of Regular Expressions (regex) to a Finite Automata. I've faced some frustrations with the papers my teacher handed out and tried to look for a solution on the internet and stumbled across some videos on YouTube. All of these videos claim that the + operator stands for or. According to my notes on regex it should stand for some sort of quantifier that matches 1 or more occurrences of the previous character and the character standing for or would be a "pipe" (|) symbol. An example of this would be (as I understand it):

Regex: /a+b/g
Matches: ab, aab, aaab,...

Regex: /a|b/g
Matches: a, b, ab, ba,...

However, according to several videos, it should match like this:

Regex: /a+b/g
Matches: a, b, ab, ba,...

The example used in the video that led me here was the following:
You are supposed to create a finite automaton of this regex: (a+b)c
According to my logic this would match abc, aabc, aaabc,.... However, in the video it's said that it matches ac and bc

Could somebody please let me know what my mistake is or where my logic is faulty? Thanks a lot in advance! Am I thinking completely wrong and Finite Automata aren't even part of regex in that sense? I'm really clueless since this is the first time I actually looked into regex and tried to understand how it works, apologies if the question is stupid.

0 Answers
Related