-- valid SRI patters
-- :%w  (id only, assumes PLS)
-- %w+:%w+ (system / id-numword)
-- %w+:%d+ (system / id-int)

-- %w+:%w+:%w+ (org/system/id-numword)
-- %w+:%w+:%d+ (org/system/id-int)


local function on_save_scan_citations( db, id, text )
   wv.log('debug','got save for record id=%s #text=%d', id, #text)


-----    local srchstart = 1
-----    while true do
-----       local s, e, system, recid = text:find('(%w+):(%w+)', srchstart )
-----       if not s then
-----          break
-----       end
-----       wv.log('debug','found possible SRI, [%d,%d] "%s:%s"', s, e, system, recid)
-----       
-----       -- @todo: run valiidity checks, ie, record id is all digits or else valid numword
-----       -- possibly enforce known systems etc
-----       table.insert( found, { s, e, sub } )
-----       srchstart = e + 1
   -----    end
   

   -- 160613 start with pls-only ids
   local found = {}
   local srchstart = 1
   while true do
      local s, e, plsid = text:find('%s:(%w+)', srchstart )
      if not s then
         break
      end
      wv.log('debug','found possible SRI, [%d,%d] ":%s"', s, e, plsid)
      
      -- @todo: run valiidity checks, ie, record id is all digits or else valid numword
      -- possibly enforce known systems etc
      table.insert( found, { s, e, plsid } )
      srchstart = e + 1
   end
   
   if #found > 0 then
   end

   -- @todo: compare list of fonud citations to current database table of citations.
end


return on_save_scan_citations