Copy all text that are exactly 4 lines before a search result.
-
Hello. I’m trying to come up with a regular expression that could select what is inside "
<text>123</text>when after we have
<fill> <color value="255,255,255"/> </fill>Also, I’d like the expression copy what is inside
<text name="title">Find and copy me</text>Here are some example. Note that the color value is always 4 lines after the <text>
A big thank you for your help :)
<draw name="id" w="6.35mm" h="4.233mm" y="1.058mm" x="160.867mm"> <ui> <textEdit> <margin/> </textEdit> </ui> <value> <text>400</text> </value> <font size="8pt" typeface="Helvetica" baselineShift="0pt" weight="bold"> <fill> <color value="255,255,255"/> </fill> </font> <margin topInset="0mm" bottomInset="0mm" leftInset="0mm" rightInset="0mm"/> <para vAlign="middle" spaceAbove="2.5pt" spaceBelow="0pt" textIndent="0pt" marginLeft="0pt" marginRight="0pt" hAlign="center" lineHeight="9pt"/> <border> <edge presence="hidden"/> <corner presence="hidden" thickness="0.1764mm"/> <fill> <color value="0,0,0"/> </fill> </border> <desc> <text name="ObjectVersion">Release 6.0 - October 17, 2014</text> <text name="ObjectName">LineNumber_FillBlack_White100</text> </desc> <traversal> <traverse ref="form1[0].Page5[0].P10[0].Ln400[0].lbl[0]"/> </traversal> </draw> <text name="title">Find and copy me</text> -
Hello, @david-l and All,
If I fully understood what you said :
Given your INPUT text, below :
<draw name="id" w="6.35mm" h="4.233mm" y="1.058mm" x="160.867mm"> <ui> <textEdit> <margin/> </textEdit> </ui> <value> <text>400</text> </value> <font size="8pt" typeface="Helvetica" baselineShift="0pt" weight="bold"> <fill> <color value="255,255,255"/> </fill> </font> <margin topInset="0mm" bottomInset="0mm" leftInset="0mm" rightInset="0mm"/> <para vAlign="middle" spaceAbove="2.5pt" spaceBelow="0pt" textIndent="0pt" marginLeft="0pt" marginRight="0pt" hAlign="center" lineHeight="9pt"/> <border> <edge presence="hidden"/> <corner presence="hidden" thickness="0.1764mm"/> <fill> <color value="0,0,0"/> </fill> </border> <desc> <text name="ObjectVersion">Release 6.0 - October 17, 2014</text> <text name="ObjectName">LineNumber_FillBlack_White100</text> </desc> <traversal> <traverse ref="form1[0].Page5[0].P10[0].Ln400[0].lbl[0]"/> </traversal> </draw> <text name="title">Find and copy me</text>-
Open the
Markdialog -
Uncheck all box options
-
MARK
<text name=.+>\K.+(?=</text>)|(?<=<text>).+(?=</text>\R(?:.+\R){3}\h*<color) -
Check the two options
Purge for each searchandWrap around -
Select the
Regular expressionsearch mode -
Click on the
Mark Allbutton -
Click on the
Copy Marked Textbutton -
Open a new tab
-
Paste the clipboard contents (
Ctrl + V)
Voila !
However, I almost certain that it’s not exactly what you want to :-)
Best Regards,
guy038
-
-
Hello. Thank you for your help and your time.
I probably didn’t explain well ;)
the code is from a .xfa forms. There is a lot of content inside but I would like to extract only the information that are inside black boxes.
So, my idea was to search for all code that make a box black
<fill> <color value="255,255,255"/> </fill>and from here, copy the value written in this box (that is 4 lines above in the code). Here, 400
<value> <text>400</text> </value>This expression partially work. The problem is that it select the 4 lines above my color value, not only the 400
(?-is)^(.\R){4}(?=.<color value=“255,255,255”/>)again, thank you for your help :)
-
-
the message on your link is not encouraging :)
I fount the solution
I used this:
(?-is)^(.\R){4}(?=.<color value=“255,255,255”/>)
then another one on the result of the first to keep only what is between <text> and </text>All run on a macro. It’s doing the job.
Thx again :)
-
Hi, @david-l, @mark-olson and All,
@david-l, I do not understand !
The second part of my regex, AFTER the alternation symbol (
|) was :SEARCH
(?<=<text>).+(?=</text>\R(?:.+\R){3}\h*<color)That I, now, improved as :
SEARCH
(?-is)(?<=<text>).+(?=</text>\R(?:.+\R){3}\h*<color value="255,255,255"/>)and these both regexes just match the string
400, against the INPUT text below, not more :<value> <text>400</text> </value> <font size="8pt" typeface="Helvetica" baselineShift="0pt" weight="bold"> <fill> <color value="255,255,255"/> </fill>So what ?
Now, @david-l, in your first post, you said :
Also, I’d like the expression copy what is inside
<text name=“title”>Find and copy me</text>
This was considered in the first part of my regex :
SEARCH / MARK
<text name=.+>\K.+(?=</text>)which does find the stringFind and copy meonly, against the INPUT text, below :<text name="title">Find and copy me</text>
Now, may be it’s because i’m not fluent with the
HYMLlanguage but, in your second post, you said :So, my idea was to search for all code that make a box black
<fill> <color value="255,255,255"/> </fill>And, obviously, the color referenced is the white color ! So what ?
Sorry, I’m a bit lost !!
BR
guy038
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