Decyphering a simple regex

后端 未结 3 1938
失恋的感觉
失恋的感觉 2020-12-04 03:26

The regular expression in question is

(\\d{3,4}[.-]?)+

sample text

707-7019-789

My progress so far

<
3条回答
  •  一向
    一向 (楼主)
    2020-12-04 04:08

    The brackets remove the functionality of the dot. Brackets mean "Range"/"Character class". Thus you are saying Choose from the list/range/character class .- You aren't saying choose from the list "anything"- (anything is the regular meaning of .)

提交回复
热议问题