Page 1 of 1

Find and replace bullet points

Posted: 13 Jul 2018, 09:06
by Tobister
Hi all,

as you can see, I am new to the community :) I encountered a challenge for which I was not able to find a solution to yet:

I have a text in a text processing editor like MS Word. I need to paste this text into a plattform which misinterprets carriage returns, new lines and bullet points. To edit the carriage returns and new lines, I have already built the following code which works fine:

Code: Select all

		clipboard =  ; Start off empty
			Sleep 200
		Send ^c
			Sleep 200
			Clipboard := StrReplace(Clipboard,"`r`n","|*")
			Sleep 200
			Send, %clipboard%
Now my question: Does anyone of you know an idea of how to get this:
  • One
  • Two
  • Three
To
One|*Two|*Three
I could not find a string that I can search for when looking for a bullet point of a list. I already tried "\u2022".

Thank you so much
Tobi

Re: Find and replace bullet points

Posted: 13 Jul 2018, 12:34
by Qysh

Code: Select all

	clipboard =  ; Start off empty
			Sleep 200
		Send ^c
			Sleep 200
			Clipboard := StrReplace(StrReplace(Clipboard,"•",""),"`r`n","|*")
			Sleep 200
			Send, %clipboard%

Re: Find and replace bullet points

Posted: 13 Jul 2018, 12:53
by colt
Another way could be to strip your clipboard of all symbols except for |*. I am assuming that the text is only letters and numbers. This way if your bullet point style changes you will not have to rewrite your code.

Code: Select all

output:= StrReplace(Clipboard,"`r`n","|*")
output:= RegExReplace(output, "i)[^0-9a-z|*]")
msgbox %output%

Re: Find and replace bullet points

Posted: 13 Jul 2018, 20:30
by jeeswg
Try this. Cheers.

Code: Select all

;tested on Word 2007
q:: ;MS Word - replace bullet points
Clipboard := ""
SendInput, ^c
ClipWait, 3
if ErrorLevel
{
	MsgBox, % "error: failed to retrieve clipboard text"
	return
}
vOutput := StrReplace(Clipboard, "`r`n" Chr(8226) "`t", "|*")
vOutput := RegExReplace(vOutput, "(^|`r`n)\Q|*\E", "$1") ;CRLF followed by |* -> CRLF, and, remove |* if string starts with |*
Clipboard := vOutput
MsgBox, % "[" vOutput "]"
return