From b9825a164646e3e5a0afea98915c517fbac3ac95 Mon Sep 17 00:00:00 2001 From: Jonathan Silverblood Date: Sat, 29 Sep 2018 19:27:49 +0000 Subject: [PATCH] Add whitespace and linebreaks to the regular expressions to make them clearer, and add a note explaining that the whitespace and linebreaks should be removed before use. --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 11d8dbf..65ff3e4 100644 --- a/README.md +++ b/README.md @@ -365,19 +365,65 @@ In order to reduce implementation costs and increase implementation conformity, ### Regular expressions +*The expressions listed here is shown with whitespace and linebreaks for clarity and ease of updating and should be removed before use. + To parse a **Challenge request** into its parts -```javascript -/(?Pcashid:)[\/]*(?P[^\/]+)(?P\/[^\?]+)(?P\?.+)?/ +```regexp +/ + (?Pcashid:) + (?:[\/]{2})? + (?P[^\/]+) + (?P\/[^\?]+) + (?P\?.+) +/ ``` To parse the **Parameters** into their parts -```javascript -/(?:[\?\&]a=)(?P[^\&]+)?(?:[\?\&]d=)(?P[^\&]+)?(?:[\?\&]r=)(?P[^\&]+)?(?:[\?\&]o=)(?P[^\&]+)?(?:[\?\&]x=)(?P[^\&]+)?/ +```regexp +/ + (?:[\?\&]a=)(?P[^\&]+)? + (?:[\?\&]d=)(?P[^\&]+)? + (?:[\?\&]r=)(?P[^\&]+)? + (?:[\?\&]o=)(?P[^\&]+)? + (?:[\?\&]x=)(?P[^\&]+)? +/ ``` To parse the **Metadata** fields into their parts -```javascript -/(i(?P(?![1-9]+))?(?P1)?(?P2)?(?P3)?(?P4)?(?P5)?(?P6)?(?P8)?(?P9)?)?(p(?P(?![1-9]+))?(?P1)?(?P2)?(?P3)?(?P4)?(?P5)?(?P6)?(?P9)?)?(c(?P(?![1-9]+))?(?P1)?(?P2)?(?P3)?(?P4)?(?P5)?(?P6)?(?P9)?)?/ +```regexp +/ + (i + (?P(?![1-9]+))? + (?P1)? + (?P2)? + (?P3)? + (?P4)? + (?P5)? + (?P6)? + (?P8)? + (?P9)? + )? + (p + (?P(?![1-9]+))? + (?P1)? + (?P2)? + (?P3)? + (?P4)? + (?P5)? + (?P6)? + (?P9)? + )? + (c + (?P(?![1-9]+))? + (?P1)? + (?P2)? + (?P3)? + (?P4)? + (?P5)? + (?P6)? + (?P9)? + )? +/ ```