Jump to content

Recommended Posts

Posted

HI helper, 

I have a small problem:

I'm trying to copy a text, but need only the first paragraph.

Example text:

Viscom has developed its X-ray systems to the point where X-ray inspection can be used for large, heavy objects automatically and inline during production.
 
This article was originally published in the March 2020 edition of U.S. Tech. 
 
 
So what i'm looking is having the first paragraph (sometimes the paragraph is more then one line) only and set it into clipboard or a variable.

 

  • Fadi changed the title to Copy text before empty line and set it into clipboard
Posted
4 hours ago, Fadi said:

So what i'm looking is having the first paragraph (sometimes the paragraph is more then one line) only [...]

You should specify (your) rules to define the end of the first paragraph. By default, a sentence ends with a dot.

Example : "This is sentence number one. This is sentence number two." ==> The text before the first dot should be selected.

However, this rule would be insufficient for sentences e.g. like : "All *.exe files are copied. Other extensions will be ignored."

Some extended examples, in which you mark the desired part, would be helpful. Later this part can be extracted using RegEx or string operations.

Posted

Maybe this example.

; https://books.google.com.au/books?id=IyhVAAAAYAAJ&dq=two+CRLF%27s+end+a+paragraph&focus=searchwithinvolume&q=two+CRLF
Local $sExampleText = _
        "Viscom1 has developed its X-ray systems to the point where X-ray inspection can be used for large, " & _
        "heavy objects automatically and inline during production." & @CRLF & @CRLF & _
        "This article was originally published in the March 2020 edition of U.S. Tech."
ConsoleWrite($sExampleText & @CRLF & "-----------------------------------------------------------" & @CRLF)

ClipPut(StringRegExpReplace($sExampleText, "\R{2,}.+$", ""))
ConsoleWrite(ClipGet() & @CRLF)

 

Posted

It's not a default text.

User will enter a text in a field and what i need is to catch the first paragraph.

i know if i move my mouse over the paragraph and hit the left mouse 3 times, will select this paragraph.

Any other way?

  • 4 weeks later...
Posted (edited)

This may be a little late to help you but you might want to try finding 2 @CRLF in a row.  If that doesn't exist then there is probably just one paragraph.

Actually that's what @Malkey's regex expression does.  Sorry my regex is weak so I didn't know until I looked harder at it.

Edited by wolflake

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...