Regular Expressions 101

Community Patterns

1...56789...902

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
(^\/.*)?(\/$|\/(\?.*))
/
gm

Description

It extracts 3 groups

  1. before trailing slash
  2. trailing slash
  3. queryString ?name1=value1

Then, combing group 1 and group 3. Group 1 and Group 3 are optional

Submitted by anonymous - 6 years ago