Regular Expressions 101

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(queryStringParameters=[^&]*&?)
/
gm

Description

The first part is the query’s name and the ‘=’. Keep in mind that the query may be one of many and between or before other queries that we want to remain. The next part of the expression, ‘[^&]’, is targeting any character that is not an ampersand so that it stops before the next query. The asterisk is there representing 0 or more of the preceding character, so it will cover us if it is the last query. If there’s an ampersand after the query parameter, we also want to remove it to prevent something like this from showing up “/blog/post-23?lang=en&&x1=key4929”.

Submitted by anonymous - 6 years ago