Are the regular expressions the same?

In summary, the two regular expressions being compared are not equal because one contains the intersection operator, which makes it not a valid regular expression. This was clarified by the conversation between the two individuals.
  • #1
evinda
Gold Member
MHB
3,836
0
Hi!I have also an other question.

Is the regular expression $\{\{a,b,c\}^{*} \cdot aba \cdot \{a,b,c\}^{*}\}\cap\{\{a,b,c\}^{*} \cdot cbc \cdot \{a,b,c\}^{*}\}$ equal to this one: $\{\{a,b,c\}^{*} \cdot aba \cdot \{a,b,c\}^{*} \cdot cbc \cdot \{a,b,c\}^{*}$ or is there a difference?
 
Technology news on Phys.org
  • #2
$\{\{a,b,c\}^{*} \cdot aba \cdot \{a,b,c\}^{*}\}\cap\{\{a,b,c\}^{*} \cdot cbc \cdot \{a,b,c\}^{*}\}$ is not a regular expression because it contains $\cap$.
 
  • #3
Evgeny.Makarov said:
$\{\{a,b,c\}^{*} \cdot aba \cdot \{a,b,c\}^{*}\}\cap\{\{a,b,c\}^{*} \cdot cbc \cdot \{a,b,c\}^{*}\}$ is not a regular expression because it contains $\cap$.

I understand...Thank you very much! :eek:
 

Related to Are the regular expressions the same?

1. Are regular expressions case sensitive?

Yes, regular expressions are case sensitive by default. This means that uppercase and lowercase letters are treated as different characters in the expression. However, some programming languages and tools have options to make regular expressions case insensitive.

2. Can regular expressions match multiple patterns?

Yes, regular expressions can match multiple patterns within a string. This is achieved by using special characters such as the pipe (|) symbol to indicate alternative patterns. For example, the regular expression "cat|dog" would match either "cat" or "dog" within a string.

3. What is the difference between greedy and lazy matching?

Greedy matching is the default behavior of regular expressions, where the expression will match as much of the string as possible. Lazy matching, on the other hand, will match as little of the string as possible. This can be useful when dealing with long or complex strings, as it can prevent unnecessary processing.

4. Can regular expressions be used to validate user input?

Yes, regular expressions are commonly used for form validation. They can be used to check if user input matches a specific pattern, such as a valid email address or phone number. This can help ensure that data entered by users is in the correct format before being processed.

5. How do I learn and use regular expressions?

There are many online resources and tutorials available for learning and using regular expressions. Some popular resources include RegexOne, RegExr, and Regular-Expressions.info. It is also helpful to practice using regular expressions in a programming language or tool that supports them, such as JavaScript or Notepad++.

Similar threads

  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
583
  • Calculus and Beyond Homework Help
Replies
2
Views
412
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
1K
  • General Math
Replies
3
Views
582
  • Introductory Physics Homework Help
Replies
2
Views
353
Replies
3
Views
736
  • Introductory Physics Homework Help
Replies
6
Views
880
Back
Top