What is [50-99] in regular expression?

In summary, the conversation discusses resources for learning regular expressions and the meaning of the character set [50-99]. It is clarified that [50-99] is equivalent to [0-9], and a recommended website for learning regular expressions is mentioned. The concept of character ranges is also explained, with an example showing how [50-99] is interpreted as a pair of characters.
  • #1
shivajikobardan
674
54
TL;DR Summary
regular expression character set meaning for [50-99]?
As the slide says, it's not 50-99 characters so what it is?

PDxPmiqvcz9UjWNJKyeZR2DyyMOULpLAZS0IaLfjCjF0kCR-sA.png

Source: https://www3.cs.stonybrook.edu/~pfodor/courses/CSE307/L02_Programming_RE.pdf

Also, please tell me how to learn regular expressions? Recommend some university/any courses to take for learning regular expression for backend development. (Not the one we learnt in theory of automata and computation).

There are lots of resources to learn it like regexpal for testing regular expressions, regexone.com for learning it. But how'd you learn it? Like what process do you follow to learn it?
 
Technology news on Phys.org
  • #2
shivajikobardan said:
TL;DR Summary: regular expression character set meaning for [50-99]?

As the slide says, it's not 50-99 characters so what it is?
The answer is in the slide: [50-99] is the same as [0-9]. Why do you think this is?
[5] matches a 5, [9] matches a 9, [59] matches a 5 or a 9, [0-9] matches any character 0-9
shivajikobardan said:
regexone.com for learning it. But how'd you learn it? Like what process do you follow to learn it?
I had not seen https://regexone.com/ before: it looks really good so learn from that.
 
  • #3
A key idea on the page about character ranges is this:
represent all characters between two characters
So 50 and 99 are not treated as numbers, but rather as a pair of characters each,
 
  • #4
but I tried in regexpal, [50-99] matches number between 50-99 as well? @pbuk

edit: I'm wrong it also matches 98888
 
  • #5
I got it. it's [5,0-9,9] that's why.
 
  • Like
Likes pbuk

1. What is a regular expression?

A regular expression, also known as regex, is a sequence of characters that define a pattern used to search for and match strings of text. It is a powerful tool for manipulating and extracting specific information from large amounts of data.

2. How do I read a regular expression?

Regular expressions are read from left to right. Each character or metacharacter in the expression represents a specific rule or pattern to match against the text. For example, the expression [a-z] would match any lowercase letter from a to z.

3. What does the range [50-99] mean in a regular expression?

The range [50-99] in a regular expression means that any number between 50 and 99, inclusive, will be matched. This can be useful for matching specific numbers or a range of numbers within a larger string.

4. Can I use regular expressions in any programming language?

Yes, regular expressions are supported in most programming languages, including Java, Python, JavaScript, and more. Each language may have slight variations in syntax, but the basic principles of regular expressions remain the same.

5. Are regular expressions case-sensitive?

Yes, regular expressions are typically case-sensitive. This means that uppercase and lowercase letters are treated as different characters and must match exactly in order to be considered a match. However, some programming languages allow for case-insensitive matching options in regular expressions.

Similar threads

Replies
2
Views
1K
Replies
1
Views
816
  • Programming and Computer Science
Replies
2
Views
1K
Replies
2
Views
885
  • Programming and Computer Science
Replies
29
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • Science and Math Textbooks
Replies
1
Views
1K
  • STEM Academic Advising
Replies
9
Views
1K
  • STEM Academic Advising
Replies
1
Views
929
Back
Top