0 votes
25 years ago I learned CC tables, and got pretty good at it. Now I am trying to get with the times and learn regular expressions since  I somehow got the impression that changes.txt in PTXPrint used them. However, the regular expressions that I am (finally) getting to do what I want them to do on one of those tutorial websites, don't seem to work when I put them in changes.txt. A simple one-to-one change is no problem, but when I try to use (for instance) parentheses on one side of the > and then a back reference \1 on the other side, it doesn't work. I have an idea that I am missing details about the specific syntax of the implementation in PTXPrint. Is there any documentation about what the syntax for changes.txt is? Or what subset of RegEx it supports?

PS - Managed to get my expression to work in Reg Ex Pal in PTX, too.
PTXprint by (155 points)
edited by

2 Answers

0 votes
Solved my own problem. Seems both sides of the change need to have double quotations marks around the entirety of the regex expression, not just around literals. I am still wondering whether there is more documentation somewhere on this. For example, I know about "at GAL 1:5 ...." but it seems that somewhere I saw something (maybe on one of the videos) using a different preposition than "at". Would love to know what those might be, but despair of ever finding it again in the videos or powerpoint slides. Would also like to know what the syntax is for addressing individual paragraphs in introduction material. Can do that in Adjust lists (e.g. GAL 0.1  -1[13]) but this syntax doesn't seem to work in changes.txt. Again, hate to bother you all for every little detail, so would love to know where it is all written down.
by (155 points)
edited by
0 votes

Yes, indeed, we do support Regex (and specifically the python flavour). You are correct that backslash codes such as \p must be escaped with a \ so that they appear as \\p.

Here are some examples of the kinds of things that you can do:

# Make space before last word in a section heading a Non-breaking space.
"(\\s( \S+)+) (\S+\s*\r?\n)"  > "\1\u00A0\3"

# If you only want the 3-letter book code to appear in the alternate header \h1 field (to help with typesetting)
"(\\id (...).+\n)" > "\1\\h1 \2\r\n"

# Change any normal \p at the start of chapters which really look like they should be no-break paragraph \nb
# at 2CO  2:0; 2CO  7:0; COL  2:0; COL  4:0; HEB 10:0  "\\p" > "\\nb"

# Shrink the paragraph starting at EXO 29:2 by 2%
at EXO 29:1 "\\p" > "\\p^98"

# Remove the \b after a \d within the book of PSA
at PSA "(\\d .+?[\r\n])\\b[\s\r\n]" > "\1"

# Remove \b after a \s section heading
"(\\s .+?[\r\n])\\b[\s\r\n]" > "\1"

# Just for certain books, insert a page break BEFORE the title of the Introductory Outline
at MAT; ROM; 1CO; PHP; COL "(\\iot )" > "\\pb\r\n\1" 

# Only for *some* books, it looks better if chapter 1 starts on its own page
at MRK; JHN; 1TI; JAS "(\\c 1 ?\r?\n)" > "\\pb\n\1"

# Wrap \io lines that are too long:
at MRK in "\\io\d [^\\]+\\ior": "ఆని పణిఙని" > "ఆని\u2028పణిఙని"
at LUK in "\\io\d [^\\]+\\ior": "బోదిసి, జబ్బుది" > "బోదిసి,\u2028జబ్బుది"

# Insert an em-dash surrounded by a couple of spaces before the ch:vs range of \io1 and \io2
# Note that this uses the IN notation, which restricts the change to only happen WITHIN the context specified.
# This is a very useful trick to make complex rules much simpler by specifying where they can apply first.
in "\\io\d .+[\r\n]": "\s([0-9]+:[0-9:\-]+)" > "~~\u2014~~\1"

# Use Small-caps instead of ALLCAPS
"CHAKRAMANG" > "\\sc Chakramang\\sc*"
at EXO 3:14 "IAWNGUOWI" > "\\sc Iawnguowi\\sc*"
at EXO 28:36, 29:6 "CHAKRAMANG VÜI CHIMSAIMA" > "\\sc Chakramang Vüi Chimsaima\\sc*"

# Shrink these paragraphs* by 3% 
# (*actually it is the \p which appears before the NEXT verse which gets shrunk)
at LEV 7:10; 13:44; 14:0; 16:19,22; 20:13,18; 24:0; 26:26; 27:8 '\\p(\s)' > '\\p^97\1'

Most of the above is documented in the slides within this massive slide stack.

by (2.3k points)
Thanks for pointing out the "slide stack". I'll spend some time studying that to see what else I can learn from them. These examples are helpful, too, in expanding my RegEx horizons. Still feeling nostalgic for CC tables, but I'll get over it.
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
But if we walk in the light, as he is in the light, we have fellowship with one another, and the blood of Jesus, his Son, purifies us from all sin.
1 John 1:7
2,427 questions
5,121 answers
4,827 comments
1,219 users