Get a word from a file, then use it in a REPLACE, hopefully in one RegEx.
-
Given:
\id NUM kulav.txt 1993 A.Horton.Luvale \h KULAVA \toc1 Mukanda waKulava \toc2 Kulava \toc3 Kula \mt2 MUKANDA WA \mt1 KULAVA \c 1 \s VaIsalele navavalava kuShinai \v 1 \nd Yehova\nd* alwezele vaMose naAlone ngwenyi \v 2 Lavenu vana vaKohate vamuli vana vaLevi kujita \v 3 kuputukila hali vamyaka makumi atatu (30) naku \v 4 Eyi yikiko milimo yavana vaKohate vamalunga mu \v 5 Omu chilombo nachikakatukanga, kuvanga Alone n \s Vana vaLevi navavatongola \c 2 \s Vihela vyajitanga hachilombo \v 1 \nd Yehova\nd* alwezele vaMose naAlone ngwenyi \v 2 Lavenu vana vaKohate vamuli vana vaLevi kujita \v 3 kuputukila hali vamyaka makumi atatu (30) naku \v 4 Eyi yikiko milimo yavana vaKohate vamalunga mu \v 5 Omu chilombo nachikakatukanga, kuvanga Alone n \c 3 \s Vana vaAlone \v 1 \nd Yehova\nd* alwezele vaMose naAlone ngwenyi \v 2 Lavenu vana vaKohate vamuli vana vaLevi kujita \v 3 kuputukila hali vamyaka makumi atatu (30) naku \v 4 Eyi yikiko milimo yavana vaKohate vamalunga mu \v 5 Omu chilombo nachikakatukanga, kuvanga Alone n \s Milimo yauLevi\f + \fr 3:5 \ft Milimo yauLevi, y \s Kusokola vatwatwa \c 4 \s VaLevi\f + \fr 4:1 \ft Milimo yauLevi, yikiko mi \v 1 \nd Yehova\nd* alwezele vaMose naAlone ngwenyi \v 2 Lavenu vana vaKohate vamuli vana vaLevi kujita \v 3 kuputukila hali vamyaka makumi atatu (30) naku \v 4 Eyi yikiko milimo yavana vaKohate vamalunga mu \v 5 Omu chilombo nachikakatukanga, kuvanga Alone n \c 5 \s Vaze navapihya mwaya Jishimbi \v 1 \nd Yehova\nd* alwezele vaMose naAlone ngwenyi \v 2 Lavenu vana vaKohate vamuli vana vaLevi kujita \v 3 kuputukila hali vamyaka makumi atatu (30) naku \v 4 Eyi yikiko milimo yavana vaKohate vamalunga mu \v 5 Omu chilombo nachikakatukanga, kuvanga Alone n \s Lushimbi lwakuvuluka kushishisa \s Lushimbi lwalisunguThis RegEx:
(?:\\toc2\s)(.+)$Puts the last word of “\toc2 Kulava” into Group 1.
I next want to:
FIND ^\c (\d+) - REPLACE Kulava $1
Since I already have “Kulava” as $1 in the first above RegEx, is there a way to combine them, and use the $1 from the first as part of the REPLACE in the second?
Thanx for any and all help.
-
@Robert-Or-Janet-Diebel said in Get a word from a file, then use it in a REPLACE, hopefully in one RegEx.:
Since I already have “Kulava” as $1 in the first above RegEx, is there a way to combine them, and use the $1 from the first as part of the REPLACE in the second?
This is very similar to the last solution I gave you.
Again you:
- Reverse the lines
- Using Find function with:
Find What:(?-s)^\\c (\d+)(?=(.*\R)+?\\toc2 (.+)$)
Replace With:${3} ${1}
Have the cursor in the first position of the file and click on Replace All. - Reverse the lines
You seem to think the find and then replacement are two separate process, but in fact it is just 1 as you can see from step #2 above.
The regular expression is actually performing 2 finds together. The first is the capture of the text which will be replaced. The second find in the same regular expression is a lookahead to find the replacement text, which is used as the replacement of the current capture. This is repeated for every
\cline with a following number which is kept.Terry
-
@Terry-R I know this kindness is above and beyond.
I have been looking, trying to help myself.This will save much time and effort.
Thanx for your patience.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login