Scripture Parsing – A unique coding problem, pt. 1


Apparently, about 85% of the world is religious, so this may not be such a unique problem after all, but for a lot of folks this may appear to be a bit of a unique problem for PHP development, or coding in general. That problem is parsing a Scripture reference. Now, there’s other uses for it as well, not just Bible references. Islam, Judaism, and Catholicism can use this as well for additional texts.

In this part (part 1), I just want to explain the problem and show some solutions you can get online right now for your project. In part 2, I’d like to explain how to actually create your own parser with PHP code, and possibly with Python or another language. Maybe Javascript? Who knows…

opened Bible

So, let’s discuss the actual problem, which is: How do I get the book, chapter, and verse from a reference? Why is this necessary? In projects that look up Scripture, it’s important to break up user input to know what the user is requesting (ex., Ref Tagger from Bible Gateway). If a user enters in “John 3:16”, the program needs to know what is the book (ie., John), and what is the chapter (ie., 3), and what is the verse. Sometimes this can get a lot more complex because the user may be describing whole sections of the Bible, or using an abbreviation for a book.

Here’s an example of various user inputs, and references:

  • 1 John 5:13
  • John 3:16
  • Jn. 3:16
  • Revelation 4:1-10:3
  • Gen. 1-3

This is obviously not exhaustive, but it demonstrates the obvious problems that you will encounter trying to parse Scripture references. We’ve got an abbreviation, we’ve got some books that have a number before them, and we have the same name as another book that doesn’t (ie., John). We also have some references that reference whole chapters and sections in the Bible. Again, in part 2, I’ll go through creating our own parser for this, but for now, here’s a few packages and PHP solutions for this problem.

Packages & PHP code that parse Bible Verses

Let me know what you think in the comments!

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments