Page 1 of 1

Need help breaking up words in clipboard with Regex

Posted: 19 Nov 2016, 21:31
by vahju
First off my Regex skills are lacking (like non-existent).

For work I have to copy some text from a internal application to gather some data.
I have worked out how to copy the entire text of a site to the clipboard as text.
Problem is the data that is need was in a table and now the column name and data have been crammed together with no spaces.
Spoiler
The line numbers are irrelevant what my goal is to insert ":::" in between "Action Item ID" and "123456".
I would like to do the same thing for line with "Finished By" so the results end up being "Finished By:::John Doe".

Below is my attempt at RegexReplace

Code: Select all

Var := RegExReplace(var, ")^Action Item ID", "Action Item ID:::")
Any help would be appreciated.

Re: Need help breaking up words in clipboard with Regex

Posted: 19 Nov 2016, 21:58
by JoeWinograd
No real need for RegEx on this one. These two very simple StringReplace statements will do it:

Code: Select all

StringReplace,Var,Var,Action Item ID,Action Item ID:::,All
StringReplace,Var,Var,Finished By,Finished By:::,All
Regards, Joe

Re: Need help breaking up words in clipboard with Regex

Posted: 19 Nov 2016, 22:11
by vahju
I tried both and nothing gets replaced.
ErrorLevel shows 0 replaced.
Below is my script just to make sure nothing else is causing the issue.

Code: Select all

var := clipboard

; ===== Set file name
FoundPos1 := RegExMatch(var, "Action Item \d+", vFileName)
FoundPos2 := RegExMatch(var, "djtpAcceptance")

If (FoundPos2 > 0)
	vFileName := "Approved " vFilename

; ===== Clean up future column headings
StringReplace,Var,Var,Action Item ID,Action Item ID:::,All
StringReplace,Var,Var,Finished By,Finished By:::,All

; ===== Write data to file to be used later in MS Power Query
FileAppend, %var%, C:\Users\me\ActionItems\%vFileName%.txt
return

Re: Need help breaking up words in clipboard with Regex  Topic is solved

Posted: 19 Nov 2016, 22:37
by JoeWinograd
I didn't look at the rest of your script, but put a MsgBox % Var statement before and after my two StringReplace statements and you'll see that it works. Or test this stand-alone:

Code: Select all

Var:="line 35 Action Item ID123456`nline 36 Finished ByJohnDoe"
MsgBox % Var
StringReplace,Var,Var,Action Item ID,Action Item ID:::,All
StringReplace,Var,Var,Finished By,Finished By:::,All
MsgBox % Var
It works.

Going back to the changes I suggested in your script, while you're at it, put in a MsgBox % vFileName before the FileAppend and check the ErrorLevel value after the FileAppend.

Re: Need help breaking up words in clipboard with Regex

Posted: 21 Nov 2016, 20:42
by vahju
It works.
Must have save the changes without reloading the script.
Thanks again.

Re: Need help breaking up words in clipboard with Regex

Posted: 21 Nov 2016, 22:51
by JoeWinograd
You're welcome. I'm glad that works for you.