Regex - If contains '%', can only contain '%20'

regex

Solution

Doesn't require a %:

/^[^%]*(%20[^%]*)*$/

Problem

I am wanting to create a regular expression for the following scenario: If a string contains the percentage character (`%`) then it can only contain the following: `%20`, and cannot be preceded by another '`%`'. So if there was for instance, `%25` it would be rejected. For instance, the following string would be valid: `http://www.test.com/?&Name=My%20Name%20Is%20Vader` But these would fail: `http://www.test.com/?&Name=My%20Name%20Is%20VadersAccountant%25` `%%%25` Any help would be greatly appreciated, Kyle EDIT: The scenario in a nutshell is that a link is written to an encoded state and then launched via JavaScript. No decoding works. I tried .net decoding and JS decoding, each having the same result - The results stay encoded when executed.

Original source