0
1.4k 次瀏覽

We have a user who has inserted a lot of \pn and some \nd inside of footnotes. We now know we need those to be +pn…*pn* and +nd…+nd* when they are in a footnote.

We’ve found that we can get sort of close by finding \ft( .?)\pn(.?)\pn* with RegEx Pal but it produces false positives.

Is there a way to confine the search to inside of a single footnote?
Thank you,
MSEAIT/LT

舊文章 - 以原文顯示
Paratext (478 點) 提出
已重新顯示 | 1.4k 次瀏覽

8 個回答

+1
最佳回答

How about using the RegEx Pal feature of searching within, i.e.
\\f .+?\\f\*:::\\pn
The syntax of .+? limits the scope to a single footnote, and within Regex Pal, the ::: tells it to only search within that single footnote

舊文章 - 以原文顯示
(418 點) 提出

That works perfectly. Thank you.

舊文章 - 以原文顯示

So where did you folks learn about the (context):::(string to find) syntax? I can’t find it in any of the RegEx Pal help. It seems like that’s a very useful thing that should be mentioned in the help! Are there other little gems out there that we should know about?

舊文章 - 以原文顯示

Hi jeffh

There is no documentation on it. Those of us who know about it probably were informed directly by Nathan Miles.

I put together a “cheat sheet” about regular expressions in the Pratext/Regexpal context. The “sheet” is now up to 4 pages. The bottom of page 3 shows:

Note that the ::: context match is not a true regular expression but a capability built in RegExPal itself.

I have attached the PDF of the sheet.

舊文章 - 以原文顯示

I’ll try to attach the PDF again.

舊文章 - 以原文顯示
0

Is there a way to use that search string in a find\replace scenario to replace the \pn with +pn?
The closest I could come up with is

Find: \f(.+?)\pn(.?)\pn*(.?)\f*:::
Replace: \f\1\+pn\2\+pn*\3\f*

I think that would work but it would take multiple passes and I’m not sure I’d trust it enough for Yes to All

舊文章 - 以原文顯示
(478 點) 提出

The following should do the trick:
Find: \\f .+?\\f\*:::(\\pn)
Replace: \\+pn
It replaces the start and end markers in one go.

Please be very careful with using .*? or .+?. Your proposed regex would find:
\f [footnote without \pn]\f* [some text] \pn, i.e. it would replace a \pn outside of a footnote.
I’m sorry that I don’t know how to describe this better: \\f .*?\\f\* is okay, \\f (.+?)\\pn most likely does not what you want. Here you can find a more thorough explanation.

舊文章 - 以原文顯示

Thank you, that’s exactly what we are after.

MSEAIT/LT

舊文章 - 以原文顯示
0

This forum only allowed zip files and images to be attached. That might be why your PDF was not showing up. I have changed the board settings to also allow PDF files to be attached, so it will hopefully work if you try again.

舊文章 - 以原文顯示
[Expert]
(16.7k 點) 提出

已重新顯示
0

Yes, please do try to attach the PDF again… I’m looking forward to seeing it! :slight_smile:

舊文章 - 以原文顯示
(1.4k 點) 提出

Did the PDF get thru?

舊文章 - 以原文顯示
0

RegEx Cheat Sheet v12 for Paratext.pdf (383.0 KB)

anon467281 - I’ve uploaded the cheatsheet pdf.

舊文章 - 以原文顯示
(9.9k 點) 提出

Where is it uploaded to? Is that something I can do?

When I click on the link you gave it does a download that I can then view. Is that what you meant by uploaded?

舊文章 - 以原文顯示
0

Yes, you “attach” a pdf file to one of these messages by using the “upload” icon. That provides a link which then allows the reader to download the “attached” file.

舊文章 - 以原文顯示
(9.9k 點) 提出
0

I got the PDF that anon848905 uploaded. Thank you!

舊文章 - 以原文顯示
(1.4k 點) 提出
0

Came to this late: here is my solution:
(?<=\\(f|ef|fe|wj))([^\\]|\\(?!(f|ef|fe|wj)\s))*?(?=\\\1\*):::\\([^f+]\w*[\s\*])
\\+\1
This adds + to tags in \f …\f*, \ef …\ef*, \fe …\fe* or \wj …\wj* that do not begin with f
For userMenu.txt
Fix embedded markers#r#(?<=\\(f|ef|fe|wj))([^\\]|\\(?!(f|ef|fe|wj)\s))*?(?=\\\1\*):::\\([^f+]\w*[\s\*])#\\+\1

舊文章 - 以原文顯示
(1.8k 點) 提出
已重新顯示

Thank you so much for your solution.

It worked well. However, there seems to be a bug somewhere in RegExPal. When I step through the replacement one location at a time, every once in a while it is not a marker that is highlighted, but a string in the body-text. If I then choose ‘No’ to the replacement, I find that the next replacement is a final maker (\pn*) and the preceding initial marker was not replaced. If I choose ‘Yes’ the correct string a few verses further down seems to have been replaced and the next string to be replaced is the final marker. So it seems that RegExPal is not highlighting the string to be replaced correctly at times. When it is wrong the windows are initially also not showing the highlighted string. The one time when I checked, the windows shows the last few lines in the chapter.

舊文章 - 以原文顯示

@anon015155 You are experiencing a bug in RegEx Pal. For some reason Find and Replace do not always highlight the correct text in the Find and Replace panes. Here are a few tips and workarounds:
In Find :

  • Click Next enough times to get to the next chapter, and then Previous. Often the correct text is now highlighted.

In Replace:

  • Look carefully at the bottom pane for the text that you expect to be changed. You will likely see that the text has been correctly changed, although incorrectly highlighted. Go ahead and click Yes.
  • Click Cancel and then do Replace again. Often the second time through the correct text is highlighted.
  • Do Extract first to review all of the places that the Find string matches. If every thing is OK do Replace First>YesTo All
舊文章 - 以原文顯示

相關問題

0
2 個回答 319 次瀏覽
在標題中使用 \pn 和 \nd 標記,會導致文字缺少其他文字所具有的某些字元屬性 例如,在 PrintDraft 和 Publishing Assistant 中,\pn \pn* 內的文字會顯示為斜體,但不像標題的其他部分那樣為粗體 ... 但在標題中使用會導致 Paratext 將這些標記顯示為紅色,即視為錯誤 這類標記應如何在標題中使用?
anon015155 153 提出 已提問 9月 26, 2018
+1
5 個回答 894 次瀏覽
我希望在特定情況下將小寫字母改為大寫--例如,我希望將冒號後的所有小寫字母改為大寫 在 RegEx Pal 中,我找不到單一的規則來實現這一點,但有一個未記錄在案的功能,允許我建立一個簡單變更的列表來執行 (注意:確實有正則表達式可以做到 ... 可能還有其他一些事情不會完全按預期工作 如果您想嘗試此方法,我建議從一個非常簡單的列表開始,然後逐步添加內容
Phil_Leckrone 9.9k 提出 已提問 3月 2, 2022
0
3 個回答 959 次瀏覽
[There is no Help topic for RegEx Pal, so I'll start this thread for myself or anyone else to add helpful ... History panic (post #3) Key terms for search: regular expression
wdavidhj 1.4k 提出 已提問 6月 5, 2019
0
1 個回答 529 次瀏覽
我發現 RegEx Pal 在 PTX 9 中的執行速度比在 PTX8 中慢得多。 此外,當它找到我想在 PTX9 專案中查看的內容時,只要我點擊專案,它經常會當機。 有其他人也遇到這兩種情況嗎? 有什麼方法可以加快它的速度或防止它當機嗎?
anon180868 195 提出 已提問 8月 23, 2021
0
3 個回答 490 次瀏覽
I cannot seem to find the EXE for Paratext RegEx Pal for PT8. Can anybody help me? Thanks, SIL+LSS+PNG
SIL LSS PNG 411 提出 已提問 3月 15, 2018
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
I appeal to you, brothers and sisters, in the name of our Lord Jesus Christ, that all of you agree with one another in what you say and that there be no divisions among you, but that you be perfectly united in mind and thought.
1 Corinthians 1:10
3,045 個問題
6,005 個回答
5,671 則評論
2,026 位使用者