zak100 Posted October 14, 2020 Share Posted October 14, 2020 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. Link to comment Share on other sites More sharing options...
ALine Posted October 14, 2020 Share Posted October 14, 2020 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. 1 Link to comment Share on other sites More sharing options...
Sensei Posted October 14, 2020 Share Posted October 14, 2020 (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/ 1 Link to comment Share on other sites More sharing options...
Ghideon Posted October 14, 2020 Share Posted October 14, 2020 (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 October 14, 2020 by Ghideon 1 Link to comment Share on other sites More sharing options...
zak100 Posted October 15, 2020 Author Share Posted October 15, 2020 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. Link to comment Share on other sites More sharing options...
Ghideon Posted October 15, 2020 Share Posted October 15, 2020 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. 1 Link to comment Share on other sites More sharing options...
Endy0816 Posted October 15, 2020 Share Posted October 15, 2020 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. 1 Link to comment Share on other sites More sharing options...
Ghideon Posted October 15, 2020 Share Posted October 15, 2020 (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 October 15, 2020 by Ghideon 1 Link to comment Share on other sites More sharing options...
zak100 Posted October 16, 2020 Author Share Posted October 16, 2020 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. Link to comment Share on other sites More sharing options...
Sensei Posted October 16, 2020 Share Posted October 16, 2020 (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 October 16, 2020 by Sensei 1 Link to comment Share on other sites More sharing options...
Ghideon Posted October 16, 2020 Share Posted October 16, 2020 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. 1 Link to comment Share on other sites More sharing options...
zak100 Posted October 16, 2020 Author Share Posted October 16, 2020 (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 October 16, 2020 by zak100 Link to comment Share on other sites More sharing options...
Ghideon Posted October 16, 2020 Share Posted October 16, 2020 (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 October 16, 2020 by Ghideon Link to comment Share on other sites More sharing options...
Sensei Posted October 19, 2020 Share Posted October 19, 2020 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 ), (....)" 1 Link to comment Share on other sites More sharing options...
Ghideon Posted October 19, 2020 Share Posted October 19, 2020 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\). Link to comment Share on other sites More sharing options...
Ghideon Posted October 20, 2020 Share Posted October 20, 2020 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 Link to comment Share on other sites More sharing options...
zak100 Posted December 13, 2020 Author Share Posted December 13, 2020 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. Link to comment Share on other sites More sharing options...
Ghideon Posted December 13, 2020 Share Posted December 13, 2020 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? Link to comment Share on other sites More sharing options...
zak100 Posted December 13, 2020 Author Share Posted December 13, 2020 (edited) Yes. But why the regexp not working? Zulfi. Edited December 13, 2020 by zak100 Link to comment Share on other sites More sharing options...
Ghideon Posted December 14, 2020 Share Posted December 14, 2020 (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 *) In the regex I am familiar with, as described above there are different styles. Edited December 14, 2020 by Ghideon Link to comment Share on other sites More sharing options...
Sensei Posted December 14, 2020 Share Posted December 14, 2020 (edited) 15 hours ago, zak100 said: Please guide me. Watch some regular expression video tutorials (even couple times!). e.g. https://www.youtube.com/watch?v=sa-TUpSx1JA It is pretty good. and read some regular expression tutorials... Edited December 14, 2020 by Sensei Link to comment Share on other sites More sharing options...
HessLaura Posted September 15, 2021 Share Posted September 15, 2021 no not same Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now