[General boards] [Fall 2018 courses] [Summer 2018 courses] [Winter 2018 courses] [Older or newer terms]

Repetition in regex


#1

Just want to make sure the way {number} and \group works:
If a regex expressed as [ab]{2}, does that mean if the first letter is a, then it can be either aa and ab
but if we wrote ([ab])\1. If the first character is a, then aa is the only option here?


#2

Yes, you are right {} jst means that the pattern will be same and repeated and so [ab]{2} can be anything e.g. aa,bb,ab,ba.