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:
 

FAQ: Are the regular expressions the same?

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.

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.

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.

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.

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

Replies
17
Views
1K
Replies
4
Views
1K
Replies
3
Views
791
Replies
8
Views
2K
Replies
2
Views
661
Replies
8
Views
2K
Back
Top