Fadi Posted May 14, 2020 Posted May 14, 2020 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.
Guest Posted May 14, 2020 Posted May 14, 2020 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.
Malkey Posted May 14, 2020 Posted May 14, 2020 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)
Fadi Posted May 15, 2020 Author Posted May 15, 2020 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?
wolflake Posted June 8, 2020 Posted June 8, 2020 (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 June 8, 2020 by wolflake
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now