Title |
Test
Find
Extracting bible verses with Vim
|
Expression |
/(\d?\s?\w+),(\d+),(\d+),(/d*),/\1 \2:\3-\4/g |
Description |
I had a CSV file with following format: book,chapter,verse_start,verse_end,notes
I wanted to transform the rows to traditional english verse representations (i.e. "1 Timothy 2:2-4")
Unfortunately, this regex always puts a '-' after the verse_start, so if verse_end is empty, the translated version will have a trailing '-'.
Vim needs everything escaped, so here is the actual vim command for the substitution:
:%s/\(\d\?\s\?\w\+\),\(\d\+\),\(\d\+\),\(\d*\),/\1 \2:\3-\4/g |
Matches |
1 Timothy,2,2,4,|John,6,3,,|A,123,4,4, |
Non-Matches |
12 Timothy,2,2,4,|2 Timothy 2,2,4|A Corinthians 3,3,,|John,3,,,|John,3,,3, |
Author |
Rating:
Not yet rated.
Tyler Durkota
|
Source |
Lots of experimentation |
Your Rating |
|