Jump to content

Recommended Posts

Posted

Hi,

I have got following regular expression:

(bba U aab)*

Is this similar to:

(bba)* U (aab)*

I think they are same, please guide me.

 

Zulfi.

Posted

I believe that you are refering to logic, if this is the case then you may be attempting to replicate de Morgan's theorum. In which case you are very close. What made you believe that this expression that you came up with is correct. May you missed a small step somewhere in your logic.

Posted

(text) creates "capturing group", which can be referenced during replacing by e.g. $1, $2 etc. (or other following digit)

Use one of many on-line regular expressions debuggers, if you have any objections. Like this one for example:

https://regex101.com/

 

Posted (edited)
2 hours ago, zak100 said:

(bba U aab)*

The first regular expression gets at least one match in any input string, since the whole pattern is optional due to the placement of the star "*". It has one capturing group.
 

2 hours ago, zak100 said:

(bba)* U (aab)*

The second regular expression requires the string " U " (Capital U surrounded by spaces) to occur once while the two patterns "bba" and "aab" are optional

This regular expression has two capturing groups. 

 

2 hours ago, zak100 said:

I think they are same, please guide me.

Why do you think they are the same? It is easier to guide if you give some hint about your reasoning. 

Example:
First regular expression matches for instance the whole string:
"bba U aabbba U aab"
(The second regular expression matches the initial substring "bba U aab")


The second regular expression matches for instance the whole string:
"bbabbabba U aabaabaab"

 

Edited by Ghideon
Posted

Hi,

Thanks for your response. Sorry ALine this is automata theory. 

Ghideon: Please tell me what you ean by one and two capturing groups?

Sensei: Please give mme some example how the online debugger can help me to differentiate?

(bba U aab)*= bba, aab, aab, bba ... or empty

Can't  we not have bbabbaabaab in the above regular expression?

(bba)* U (aab)* = bba, bbabba, bbabbabba, empty, aab, aabaab

Please tell me is my answer correct?

 

Zulfi.

 

Posted
30 minutes ago, zak100 said:

Ghideon: Please tell me what you ean by one and two capturing groups?

Sorry, I thought you were familiar with regular expressions. I'll explain later

31 minutes ago, zak100 said:

(bba U aab)*= bba, aab, aab, bba ... or empty

Can't  we not have bbabbaabaab in the above regular expression?

(bba)* U (aab)* = bba, bbabba, bbabbabba, empty, aab, aabaab

Please tell me is my answer correct?

Your answer is incorrect.

 

You seem to assume that the cheater "U" has some special meaning. That is not correct. See my first post.

Posted
1 hour ago, zak100 said:

(bba U aab)*= bba, aab, aab, bba ... or empty

Can't  we not have bbabbaabaab in the above regular expression?

(bba)* U (aab)* = bba, bbabba, bbabbabba, empty, aab, aabaab

Please tell me is my answer correct?

 

Zulfi.

 

I want to say it should be:

(bba)* ∩ (aab)*

Just to be clear I'm assuming by 'U' you mean Union and by '*' negation.

 

 

Posted (edited)
43 minutes ago, Endy0816 said:

I want to say it should be:

(bba)* ∩ (aab)*

Just to be clear I'm assuming by 'U' you mean Union and by '*' negation.

Good point! 

Also points at the issues with the opening question. In regular expression union is represented by "|", it's not represented by the charter "U".


@zak100 Maybe you could clarify if actually wish to discuss regular expressions* or something else? Its not obvious if you try to solve an issue with programming syntax or have a more general issue with sets, logic or similar. Also, just a friendly reminder; we are on a discussion forum, your short questions "please tell me", "please give examples" etc does not, in my opinion, promote fruitful discussions. They are more suitable for entering into a search engine for a quick and precise answer. 

 

 

*) https://en.wikipedia.org/wiki/Regular_expression

 

 

Edited by Ghideon
Posted

Hi,

"Maybe you could clarify if actually wish to discuss regular expressions* or something else? "

I am discussing about regular expressions. Its not programming/logic, its automata theory course.

In my opening post "U" means the union, its same as "+" and I am talking about regular expression. "*" means zero or more repititions. I don't know about negative.

"Also, just a friendly reminder; we are on a discussion forum, your short questions "please tell me", "please give examples" etc does not, in my opinion, promote fruitful discussions."

Whatever information, I have I used to provide, i.e. code, images and expressions. If you need more information please let me know.

Zulfi.

Posted (edited)
13 minutes ago, zak100 said:

In my opening post "U" means the union,

No, in regular expressions it does NOT mean union....

https://stackoverflow.com/questions/8020848/how-is-the-and-or-operator-represented-as-in-regular-expressions

 

You mixed two different independent things. Regular expressions with mathematics (set theory)..

 

On 10/15/2020 at 6:27 AM, zak100 said:

Sensei: Please give mme some example how the online debugger can help me to differentiate?

If you would enter a sample regular expression with a sample text string into the online debugger, you should see that it doesn't work as you think.

 

Edited by Sensei
Posted
38 minutes ago, zak100 said:

I am discussing about regular expressions. Its not programming/logic, its automata theory course.

Ok. Then we can drop the examples and start from the basic.

43 minutes ago, zak100 said:

In my opening post "U" means the union, its same as "+" and I am talking about regular expression.

 

45 minutes ago, zak100 said:

Whatever information, I have I used to provide, i.e. code, images and expressions. If you need more information please let me know.

For instance what kind of regular expression you use. There are different variants with different syntax. If you want to use your own personal syntax you need to tell us all the rules you have invented. 

Posted (edited)

Hi,

I am following the syntax of our teacher and he says that "U" is for union and it is same as "+" or logical "or" operator. I don't know what you mean by union. Sorry for not specifying this earlier.

Please tell me what you guys mean by "U" in the context of regular expression?

 

Sensei: I would try the calculator and then let you know.

 

Zulfi.
 

Edited by zak100
Posted (edited)
1 hour ago, zak100 said:

I am following the syntax of our teacher and he says that "U" is for union and it is same as "+" or logical "or" operator. I don't know what you mean by union. Sorry for not specifying this earlier.

Can you show us a reference where the teacher tells what kind of regular expression they use? Are you sure they actually discuss regular expression?

1 hour ago, zak100 said:

Please tell me what you guys mean by "U" in the context of regular expression?

It is a character. The regular expression U has a match in the text ”Us” but there is no match in the text ”Bar”

In other words, there is nothing special about U.

reference: https://www.rexegg.com/regex-quickstart.html

Edited by Ghideon
Posted
On 10/16/2020 at 3:29 PM, zak100 said:

I am following the syntax of our teacher and he says that "U" is for union and it is same as "+" or logical "or" operator.

Simply, it is not true.

Regular expression has some special characters with special meanings. "U" is not one of them. It is normal letter from point of view of regex.

https://www.google.com/search?q=regular+expression+special+characters

"In the regex flavors discussed in this tutorial, there are 12 characters with special meanings: the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing parenthesis ),  (....)"

Posted
21 minutes ago, Sensei said:

Simply, it is not true.

I agree.

Good list of special characters. Just an additional note @zak100

On 10/16/2020 at 7:47 AM, Ghideon said:

There are different variants with different syntax

You never told us what you or your teacher uses so you need to be aware that in some cases the escaping differs among regular expression styles. Some platforms use backslash to escape parenthesis: \(regexp\).

 

 

Posted
On 10/19/2020 at 1:05 PM, Ghideon said:

Some platforms use backslash to escape parenthesis: regexp

I missed that the forum handles backlash + parenthesis specially. I meant:

\(regexp\)

 

  • 1 month later...
Posted
Hi,
 

\(S→Ad,A→aAa|bAb|c\

What I understand that 'd' is not allowed in the middle. Based upon this :

\(S--> aSaS)\

\(--->bSbS)\

\(--->c)\

\(---->d)\

I think that the above rules are not correct because we can put 'd' in the middle.

 

Please guide me.

Zulfi.

 

Posted
17 minutes ago, zak100 said:

I think that the above rules are not correct because we can put 'd' in the middle.

Is this still regarding regular expressions? 

Posted (edited)
10 hours ago, zak100 said:

But why the regexp not working?

Because they have syntax errors. Trailing back slash is not allowed*

Also note that what ever the arrows are supposed to mean they have no special meaning in regular expressions. The arrows will be matched literally

image.png.a476350c2ac7c39c0866d330d151a7bb.png

 

*) In the regex I am familiar with, as described above there are different styles.

Edited by Ghideon
  • 9 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.