What is [50-99] in regular expression?

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Expression Regular
Click For Summary

Discussion Overview

The discussion revolves around the interpretation of the regular expression character set notation [50-99]. Participants explore what this notation means, particularly in the context of character ranges versus numerical ranges, and seek clarification on learning resources for regular expressions.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant questions the meaning of [50-99] and states it is not referring to 50-99 characters.
  • Another participant suggests that [50-99] is equivalent to [0-9], prompting a query about the reasoning behind this interpretation.
  • A participant clarifies that character ranges represent all characters between two characters, indicating that 50 and 99 are treated as character pairs rather than numerical values.
  • One participant reports that in testing with regexpal, [50-99] appears to match numbers between 50 and 99, but later corrects themselves, noting it also matches other sequences like 98888.
  • A participant concludes that the correct interpretation involves [5,0-9,9], suggesting a misunderstanding of the character set notation.

Areas of Agreement / Disagreement

Participants express differing interpretations of the regular expression notation, with no consensus reached on its meaning. The discussion remains unresolved regarding the exact behavior of [50-99].

Contextual Notes

There are limitations in understanding the character set notation, particularly regarding how characters are interpreted versus numerical values. The discussion reflects varying levels of familiarity with regular expressions.

Who May Find This Useful

Individuals interested in learning about regular expressions, particularly in the context of backend development, may find the discussion and resources shared relevant.

shivajikobardan
Messages
637
Reaction score
54
TL;DR
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
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.
 
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,
 
but I tried in regexpal, [50-99] matches number between 50-99 as well? @pbuk

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

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
1
Views
3K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
29
Views
5K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 9 ·
Replies
9
Views
3K