Difference between revisions of "Module:StringHelpers"

From Data JW United
Jump to navigation Jump to search
(Created page with "local p = {} function p.getParagraphFromQuestion(param) string = param.args[1] return string.find(s, '-', 1, true) end return p")
 
Line 2: Line 2:
  
 
function p.getParagraphFromQuestion(param)
 
function p.getParagraphFromQuestion(param)
string = param.args[1]
+
return string.find(param.args[1], '-', 1, true)
return string.find(s, '-', 1, true)
 
 
end
 
end
  
 
return p
 
return p

Revision as of 12:57, 12 April 2020

Module supports numbers with max 3 digits.

Tests

Simple question

Expected Actual
150
15
7
150
15
7

Complex question

Expected Actual
6 1111
7 1111
10 1212
99 1212
101 1313
6 22
7 22
10 33
99 33
101 44

local p = {}

function p.getParagraphFromQuestion(param)
	return string.find(param.args[1], '-', 1, true)
end

return p