Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/test/groovy/org/groovykoans/koan07/Koan07.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ and can become difficult to maintain"""
// create the same regular expression to sum the total leftovers, but this time document the regex
String regexp
// ------------ START EDITING HERE ----------------------
regexp = /(?smx)
(.*?) # item name
regexp = /(?smx) # Why smx ??? where x works fine
(.*?) # 1: item name
\s+ # space
(\d+) # number sold
(\d+) # 2: number sold
\s+ # space
(\d+) # leftover/
(\d+) # 3: leftover/
// ------------ STOP EDITING HERE ----------------------
def sum = text.findAll(regexp) { it[3].toInteger() }.sum()
// ^^ This is even more concise than the previous example! Choose the one you feel most comfortable with.
Expand Down