Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
ECMAScript (JavaScript)

/
((?:[1234]\s?)?[a--я]+)(\s?\d+(?::(?:\d+[—–-]\d+|\d+)(?:,\d+[—–-]\d+|,\d+)*(?:;\s?\d+(?::(?:\d+[—–-]\d+|\d+)(?:,\d+[—–-]\d+|,\d+)*|;))*)?)
/
ig

Description

Matches biblical strings in text. Two capture groups are used - one for the books name and another for the passages of the same book.

  • RegEx is long because it is strict!!!
  • If you want to also match books names without specified chapter and verses use: /((?:[1234]\s?)?[a-zа-я]+)(\s?\d+(?::(?:\d+[—–-]\d+|\d+)(?:,\d+[—–-]\d+|,\d+)(?:;\s?\d+(?::(?:\d+[—–-]\d+|\d+)(?:,\d+[—–-]\d+|,\d+)|;))*)?)?/ig
Submitted by Desislavsd - 9 years ago