Regex group and set

Estimated reading time: 2 minutes

group

group represent by () .

/(kamal)(\s)(the)(\s)(boss)(\.)/
// kamal the boss.

set

set represent by []

set a-z

/[a-z]/
//kamal is a developer of node.js . He is head of Idea's of Nishi IT Ltd.

set A-Z

/[A-Z]/
//kamal is a developer of node.js . He is head of Idea's of Nishi IT Ltd.

set package

/[a-zA-Z0-9]/
//kamal is a developer of node.js . He is head of Idea's of Nishi IT Ltd.  017512

set [kid]

/[kid]/
//kamal is a developer of node.js . He is head of Idea's of Nishi IT Ltd.

set not

/[^kid]/
//kamal is a developer of node.js . He is head of Idea's of Nishi IT Ltd.

limit bracket

/[0-9]{1,4}/
// 5.12765487565656554545454545454545454545455465

limit bracket 2

/[0-9]{2,4}/
/[\d]{2,4}/
// 5.12765487565656554545454545454545454545455465

[0-9] and [\d] same

bd phn valid

const regex = /(\+){0,1}(88){0,1}01(3|7|8|6|9|5)(\d){8}/;
var result = regex.exec('+8801751255157');
console.log(result)

/* output

[
  '+8801751255157',
  '+',
  '88',
  '7',
  '7',
  index: 0,
  input: '+8801751255157'
]
/*
regex, js