Skip to content

Commit bd8a291

Browse files
Fix nonEmptyRegex implementation (#269)
* Fix nonEmptyRegex implementation Any string ending with a whitespace was considered as an empty string. * Simplify nonEmptyRegex solution Co-authored-by: Miles Frain <[email protected]>
1 parent 4ca5fec commit bd8a291

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

exercises/chapter7/test/Main.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ Note to reader: Delete this line to expand comment block -}
119119
nonEmptyTest "Houston" true
120120
nonEmptyTest "My Street" true
121121
nonEmptyTest "Ñóñá" true
122+
nonEmptyTest " Start with whitespace" true
123+
nonEmptyTest "End with whitespace " true
122124
nonEmptyTest "" false
123125
nonEmptyTest " " false
124126
nonEmptyTest "\t" false

exercises/chapter7/test/no-peeking/Solutions.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ stateRegex = regex "^[a-zA-Z]{2}$" noFlags
5454

5555
-- Exercise 2
5656
nonEmptyRegex :: Either String Regex
57-
nonEmptyRegex = regex "[^\\s]$" noFlags
57+
nonEmptyRegex = regex "\\S" noFlags
5858

5959
-- Exercise 3
6060
validateAddressImproved :: Address -> V Errors Address

0 commit comments

Comments
 (0)