Модуль:Песочница/stannic/regexp

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску
Документация

[%d%s] and [%s%d] detect the same occurrences

'314159265'

  • string.match('314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '314159265'
  • string.match('314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '314159265'
  • mw.ustring.match('314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '314159265'
  • mw.ustring.match('314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '314159265'

'-314159265'

  • string.match('-314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-314159265'
  • string.match('-314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-314159265'
  • mw.ustring.match('-314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-314159265'
  • mw.ustring.match('-314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-314159265'

'- 314159265'

  • string.match('- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 314159265'
  • string.match('- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 314159265'
  • mw.ustring.match('- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 314159265'
  • mw.ustring.match('- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 314159265'

'  314159265   '

  • string.match('  314159265   ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '  314159265   '
  • string.match('  314159265   ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '  314159265   '
  • mw.ustring.match('  314159265   ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '  314159265   '
  • mw.ustring.match('  314159265   ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '  314159265   '

'314159265a'

  • string.match('314159265a', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('314159265a', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('314159265a', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('314159265a', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'a314159265'

  • string.match('a314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('a314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('a314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('a314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'3141a59265'

  • string.match('3141a59265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('3141a59265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('3141a59265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('3141a59265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'314-159265'

  • string.match('314-159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('314-159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('314-159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('314-159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'314159265-'

  • string.match('314159265-', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('314159265-', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('314159265-', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('314159265-', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'--314159265'

  • string.match('--314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('--314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('--314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('--314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'-- 314159265'

  • string.match('-- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('-- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('-- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('-- 314159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'-- 314 159 265'

  • string.match('-- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('-- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('-- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('-- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

'  -- 314 159 265  '

  • string.match('  -- 314 159 265  ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • string.match('  -- 314 159 265  ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil
  • mw.ustring.match('  -- 314 159 265  ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == nil
  • mw.ustring.match('  -- 314 159 265  ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == nil

[%d%s] and [%s%d] do not detect the same occurrences

'314 159265'

  • string.match('314 159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '314 159265'
  • string.match('314 159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '314 159265'
  • mw.ustring.match('314 159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '314 159265'
  • mw.ustring.match('314 159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '314 159265'

'-314 159265'

  • string.match('-314 159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-314 159265'
  • string.match('-314 159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-314 159265'
  • mw.ustring.match('-314 159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-314 159265'
  • mw.ustring.match('-314 159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-314 159265'

'- 314 159265'

  • string.match('- 314 159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 314 159265'
  • string.match('- 314 159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 314 159265'
  • mw.ustring.match('- 314 159265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 314 159265'
  • mw.ustring.match('- 314 159265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 314 159265'

'314 159 265'

  • string.match('314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '314 159 265'
  • string.match('314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '314 159 265'
  • mw.ustring.match('314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '314 159 265'
  • mw.ustring.match('314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '314 159 265'

'-314 159 265'

  • string.match('-314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-314 159 265'
  • string.match('-314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-314 159 265'
  • mw.ustring.match('-314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-314 159 265'
  • mw.ustring.match('-314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-314 159 265'

'- 314 159 265'

  • string.match('- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 314 159 265'
  • string.match('- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 314 159 265'
  • mw.ustring.match('- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 314 159 265'
  • mw.ustring.match('- 314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 314 159 265'

'3 1 4 1 5 9 2 6 5'

  • string.match('3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '3 1 4 1 5 9 2 6 5'
  • string.match('3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '3 1 4 1 5 9 2 6 5'
  • mw.ustring.match('3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '3 1 4 1 5 9 2 6 5'
  • mw.ustring.match('3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '3 1 4 1 5 9 2 6 5'

'-3 1 4 1 5 9 2 6 5'

  • string.match('-3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-3 1 4 1 5 9 2 6 5'
  • string.match('-3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-3 1 4 1 5 9 2 6 5'
  • mw.ustring.match('-3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-3 1 4 1 5 9 2 6 5'
  • mw.ustring.match('-3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-3 1 4 1 5 9 2 6 5'

'- 3 1 4 1 5 9 2 6 5'

  • string.match('- 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 3 1 4 1 5 9 2 6 5'
  • string.match('- 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 3 1 4 1 5 9 2 6 5'
  • mw.ustring.match('- 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 3 1 4 1 5 9 2 6 5'
  • mw.ustring.match('- 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 3 1 4 1 5 9 2 6 5'

' 3 1 4 1 5 9 2 6 5'

  • string.match(' 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' 3 1 4 1 5 9 2 6 5'
  • string.match(' 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' 3 1 4 1 5 9 2 6 5'
  • mw.ustring.match(' 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' 3 1 4 1 5 9 2 6 5'
  • mw.ustring.match(' 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' 3 1 4 1 5 9 2 6 5'

' -3 1 4 1 5 9 2 6 5'

  • string.match(' -3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' -3 1 4 1 5 9 2 6 5'
  • string.match(' -3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' -3 1 4 1 5 9 2 6 5'
  • mw.ustring.match(' -3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' -3 1 4 1 5 9 2 6 5'
  • mw.ustring.match(' -3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' -3 1 4 1 5 9 2 6 5'

' - 3 1 4 1 5 9 2 6 5'

  • string.match(' - 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' - 3 1 4 1 5 9 2 6 5'
  • string.match(' - 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' - 3 1 4 1 5 9 2 6 5'
  • mw.ustring.match(' - 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' - 3 1 4 1 5 9 2 6 5'
  • mw.ustring.match(' - 3 1 4 1 5 9 2 6 5', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' - 3 1 4 1 5 9 2 6 5'

'3 1 4 1 5 9 2 6 5 '

  • string.match('3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '3 1 4 1 5 9 2 6 5 '
  • string.match('3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match('3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match('3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '3 1 4 1 5 9 2 6 5 '

'-3 1 4 1 5 9 2 6 5 '

  • string.match('-3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-3 1 4 1 5 9 2 6 5 '
  • string.match('-3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match('-3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '-3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match('-3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '-3 1 4 1 5 9 2 6 5 '

'- 3 1 4 1 5 9 2 6 5 '

  • string.match('- 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 3 1 4 1 5 9 2 6 5 '
  • string.match('- 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match('- 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == '- 3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match('- 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == '- 3 1 4 1 5 9 2 6 5 '

' 3 1 4 1 5 9 2 6 5 '

  • string.match(' 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' 3 1 4 1 5 9 2 6 5 '
  • string.match(' 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' 3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match(' 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' 3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match(' 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' 3 1 4 1 5 9 2 6 5 '

' -3 1 4 1 5 9 2 6 5 '

  • string.match(' -3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' -3 1 4 1 5 9 2 6 5 '
  • string.match(' -3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' -3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match(' -3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' -3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match(' -3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' -3 1 4 1 5 9 2 6 5 '

' - 3 1 4 1 5 9 2 6 5 '

  • string.match(' - 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' - 3 1 4 1 5 9 2 6 5 '
  • string.match(' - 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' - 3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match(' - 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$') == ' - 3 1 4 1 5 9 2 6 5 '
  • mw.ustring.match(' - 3 1 4 1 5 9 2 6 5 ', '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$') == ' - 3 1 4 1 5 9 2 6 5 '

[%d ] (at least seems to be) equivalent to [ %d]

'314159265'

  • mw.ustring.match('314159265', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == '314159265'
  • mw.ustring.match('314159265', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == '314159265'

'314 159265'

  • mw.ustring.match('314 159265', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == '314 159265'
  • mw.ustring.match('314 159265', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == '314 159265'

'314 159 265'

  • mw.ustring.match('314 159 265', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == '314 159 265'
  • mw.ustring.match('314 159 265', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == '314 159 265'

'  314 159  265   '

  • mw.ustring.match('  314 159  265   ', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == '  314 159  265   '
  • mw.ustring.match('  314 159  265   ', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == '  314 159  265   '

'-314159265'

  • mw.ustring.match('-314159265', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == '-314159265'
  • mw.ustring.match('-314159265', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == '-314159265'

'  -   314 159  265    '

  • mw.ustring.match('  -   314 159  265    ', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == '  -   314 159  265    '
  • mw.ustring.match('  -   314 159  265    ', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == '  -   314 159  265    '

'  - -  314 159  265    '

  • mw.ustring.match('  - -  314 159  265    ', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == nil
  • mw.ustring.match('  - -  314 159  265    ', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == nil

'  314- 159  265   '

  • mw.ustring.match('  314- 159  265   ', '^[%s]*[%-]?[%s]*[%d]+[%d ]*$') == nil
  • mw.ustring.match('  314- 159  265   ', '^[%s]*[%-]?[%s]*[%d]+[ %d]*$') == nil


  • p1: string.match: found, mw.ustring.match: found
p2: string.match: found, mw.ustring.match: found
  • p1: string.match: found, mw.ustring.match: found
p2: string.match: found, mw.ustring.match: found
  • p1: string.match: found, mw.ustring.match: found
p2: string.match: found, mw.ustring.match: found
  • p1: string.match: found, mw.ustring.match: found
p2: string.match: found, mw.ustring.match: found
  • p1: string.match: not found, mw.ustring.match: not found
p2: string.match: not found, mw.ustring.match: not found
  • p1: string.match: found, mw.ustring.match: found
p2: string.match: found, mw.ustring.match: found
  • p1: string.match: found, mw.ustring.match: found
p2: string.match: found, mw.ustring.match: found
  • p1: string.match: found, mw.ustring.match: found
p2: string.match: found, mw.ustring.match: found
local p = {}

function p.main2(frame)
	local e = function(s)
		if s then
			return "'''found'''"
		end
		return "'''not found'''"
	end
	local f = function(s, pattern)
		return string.match(s, pattern), mw.ustring.match(s, pattern)
	end
	local g = function(s, pattern)
		local s, u = f(s, pattern)
		s, u = e(s), e(u)
		return "string.match: " .. s .. ", mw.ustring.match: " .. u
	end
	local h = function(s)
		local p1, p2 =
		"^[%s]*[%-]?[%s]*[%d]+[%d%s]*$",
		"^[%s]*[%-]?[%s]*[%d]+[%s%d]*$"
		local r = "* p1: " .. g(s, p1) .. "\n:p2: " .. g(s, p2) .. "\n"
		return r
	end
	local o = ""
	o = o .. h("314159")
	o = o .. h("-314159")
	o = o .. h(" -314159")
	o = o .. h("- 314159")
	o = o .. h("--314159")
	o = o .. h("314 159")
	o = o .. h("-314 159")
	o = o .. h("- 314 159")
	return o
end

function esc(s)
	return mw.ustring.gsub(mw.text.nowiki(s), ' ', ' ')
end

function p.main(frame)
	local items = {}

	local add_free_text = function(text)
		table.insert(items, text .. "\n")
	end

	local add_header = function(header, lvl)
		table.insert(items, lvl .. header .. lvl)
	end

	local add_match = function(s, pattern, match_result, func_name)
		local mr
		if match_result then
			mr = "'" .. esc(match_result) .. "'"
		else
			mr = "nil"
		end
		table.insert(items,
			"* <kbd>" .. func_name .. "('"
			.. esc(s)
			.. "', '"
			.. esc(pattern)
			.. "') == "
			.. mr
			.. "</kbd>"
		)
	end

	local add_string_match = function(s, pattern)
		return add_match(s, pattern,
			string.match(s, pattern),
			"string.match")
	end

	local add_ustring_match = function(s, pattern)
		return add_match(s, pattern,
			mw.ustring.match(s, pattern),
			"mw.ustring.match")
	end

	local example_ds_sd = function(s)
		add_header("<kbd>'" .. esc(s) .. "'</kbd>", '====')
		add_string_match(s, '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$')
		add_string_match(s, '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$')
		add_ustring_match(s, '^[%s]*[%-]?[%s]*[%d]+[%d%s]*$')
		add_ustring_match(s, '^[%s]*[%-]?[%s]*[%d]+[%s%d]*$')
	end

	local example_dspace_spaced = function(s)
		add_header("<kbd>'" .. esc(s) .. "'</kbd>", '====')
		add_ustring_match(s, '^[%s]*[%-]?[%s]*[%d]+[%d ]*$')
		add_ustring_match(s, '^[%s]*[%-]?[%s]*[%d]+[ %d]*$')
	end

	add_header(esc('[%d%s] and [%s%d] detect the same occurrences'), '===')
	example_ds_sd('314159265')
	example_ds_sd('-314159265')
	example_ds_sd('- 314159265')
	example_ds_sd('  314159265   ')
	example_ds_sd('314159265a')
	example_ds_sd('a314159265')
	example_ds_sd('3141a59265')
	example_ds_sd('314-159265')
	example_ds_sd('314159265-')
	example_ds_sd('--314159265')
	example_ds_sd('-- 314159265')
	example_ds_sd('-- 314 159 265')
	example_ds_sd('  -- 314 159 265  ')

	add_header(esc('[%d%s] and [%s%d] do not detect the same occurrences'), '===')
	example_ds_sd('314 159265')
	example_ds_sd('-314 159265')
	example_ds_sd('- 314 159265')
	example_ds_sd('314 159 265')
	example_ds_sd('-314 159 265')
	example_ds_sd('- 314 159 265')
	example_ds_sd('3 1 4 1 5 9 2 6 5')
	example_ds_sd('-3 1 4 1 5 9 2 6 5')
	example_ds_sd('- 3 1 4 1 5 9 2 6 5')
	example_ds_sd(' 3 1 4 1 5 9 2 6 5')
	example_ds_sd(' -3 1 4 1 5 9 2 6 5')
	example_ds_sd(' - 3 1 4 1 5 9 2 6 5')
	example_ds_sd('3 1 4 1 5 9 2 6 5 ')
	example_ds_sd('-3 1 4 1 5 9 2 6 5 ')
	example_ds_sd('- 3 1 4 1 5 9 2 6 5 ')
	example_ds_sd(' 3 1 4 1 5 9 2 6 5 ')
	example_ds_sd(' -3 1 4 1 5 9 2 6 5 ')
	example_ds_sd(' - 3 1 4 1 5 9 2 6 5 ')

	add_header(esc('[%d ] (at least seems to be) equivalent to [ %d]'), '===')
	example_dspace_spaced('314159265')
	example_dspace_spaced('314 159265')
	example_dspace_spaced('314 159 265')
	example_dspace_spaced('  314 159  265   ')
	example_dspace_spaced('-314159265')
	example_dspace_spaced('  -   314 159  265    ')
	example_dspace_spaced('  - -  314 159  265    ')
	example_dspace_spaced('  314- 159  265   ')

	return table.concat(items, "\n") .. "\n"
end

return p