Find and replace bullet points

Get help with using AutoHotkey and its commands and hotkeys
Tobister
Posts: 1
Joined: 13 Jul 2018, 08:56

Find and replace bullet points

13 Jul 2018, 09:06

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
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: Find and replace bullet points

13 Jul 2018, 12:34

Code: Select all

clipboard = ; Start off empty Sleep 200 Send ^c Sleep 200 Clipboard := StrReplace(StrReplace(Clipboard,"•",""),"`r`n","|*") Sleep 200 Send, %clipboard%
colt
Posts: 67
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: Find and replace bullet points

13 Jul 2018, 12:53

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%
User avatar
jeeswg
Posts: 5260
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Find and replace bullet points

13 Jul 2018, 20:30

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
homepage | tutorials
[code boxes are currently not working 100%]
[click the 'Reply with quote' button on a post to see the full indented text]

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], Itman, tmplinshi and 47 guests