Good morning,
if I’m not in error, as I have understood reading several Regex documents, it is not possible to use a Regex pattern to search backward (or UP). Is it right, or did I miss anything?
Suppose to have a simple text (*.txt) document similar to this one with hundreds of [token] blocks, in which, e.g., insert the Italian translation only inside the [it-it]"MISSING" component, ignoring the already translated Italian and all the other languages strings.
[token]sm083
[en-us]"Existing ORIGINAL SOURCE text first token block"
[de-de]"Existing German translated text"
[nl-nl]"Existing Dutch translated text"
[fr-fr]"Existing French translated text"
[es-es]"Existing Spanish translated text"
[ca-es]"Existing Catalan translated text"
[pt-pt]"Existing Portuguese PT translated text"
[pt-br]"Existing Portuguese BR translated text"
[it-it]"Existing Italian translated text"
[token]sm001
[en-us]"Existing ORIGINAL SOURCE text second token block"
[de-de]"MISSING"
[nl-nl]"MISSING"
[fr-fr]"MISSING"
[es-es]"Existing Spanish translated text"
[ca-es]"MISSING"
[pt-pt]"MISSING"
[pt-br]"MISSING"
[it-it]"MISSING"
[token]sm055
[en-us]"Existing ORIGINAL SOURCE text third token block"
[de-de]"MISSING"
[nl-nl]"Existing Dutch translated text"
[fr-fr]"MISSING"
[es-es]"Existing Spanish translated text"
[ca-es]"MISSING"
[pt-pt]"MISSING"
[pt-br]"MISSING"
[it-it]"MISSING"
The final scope is to replace the “MISSING” text of the [it-it]"MISSING" line with the pertinent “Existing ORIGINAL SOURCE text” of the [en-us]"Existing ORIGINAL SOURCE text" line in order to be able to import in SDL Studio Editor just the Italian “MISSING” lines, duly amended with the word MISSING followed by the pertinent [en-us]"Existing ORIGINAL SOURCE text second/third token block" to be translated.
In fact, this is not a problem if I work manually on each single [token] block using the proper search Regex pattern:
(\[en-us\].*?")(.*?)(".*?)(\[it-it\]"MISSING")
and the replace pattern:
$1$2$3\[it-it\]"MISSING - $2"
Obviously, if I apply these patterns starting from the beginning of the file they work, but they select all the text from start of document up to the first occurrence of the [it-it]"MISSING" line and the replacement pattern doesn’t work.
At this point I have run a search for the [it-it]"MISSING" line (\[it-it\]"MISSING") but I did not found a solution to extend the selection backward (or UP) to the pertinent block [en-us]"Existing ORIGINAL SOURCE text".
Is there a pattern to do this? In the documents I have read I was not be able to find a solution.
Or, do you have an alternative pattern that could work cumulatively just on all blocks containing the [it-it]"MISSING" line starting from the beginning of the document?
Thank you.
Claudio