我在一家医生办公室做账单,我遇到了一个问题。由于EMR (电子病历)程序的工作方式有问题,免疫代码并不总是被列入图表。为了补偿这一点,我也有AHK的名字寻找免疫(危险,我知道)。直到最近,这项工作还很顺利,直到其中一名医生取消了免疫接种的命令。这会造成错误的结果,因为我为没有代码的图表(IMM94,和IMM97)提供了故障安全。我需要从一个非常大的字符串中删除单词"CANCELED:“之后的所有内容,直到该单词之后出现的第一行中断。我创建了一个相当漂亮的字符串裁剪函数来完成大部分这类工作,但是它与找出断线有问题,因为有那么多。我使用的测试用例是:
评估和计划:
这上面和下面都有很多东西,但我想从我的“取消:”字串中提取所有实例,到后面的第一行中断。
这就是我正在尝试的,还有我的功能。它不起作用,实际上,它复制了以"1“开头的行:
^L::
lString := ClipBoard
If lString Contains Canceled
fString := ClipString(lString, "CANCELED: ", "`n")
Clipboard := fString
Return
ClipString(lString, aMarker, bMarker, Only := 0)
{
If (Only = 1)
Return SubStr(SubStr(lString, 1, InStr(lString, bMarker)+StrLen(bMarker)-1), InStr(lString, aMarker))
Else
Return SubStr(lString, 1, InStr(lString, aMarker)-StrLen(aMarker)) . SubStr(lString, InStr(lString, bMarker)+StrLen(bMarker))
}发布于 2016-12-01 15:06:49
条子“取消:”以及剪贴板中每一行后面的任何文本
计划:
Clipboard := RegExReplace(Clipboard, "im)\s*CANCELLED:.*\R?", "`r`n")示例输入:
alpha
beta cancelled: ABC asldkfalsd
delta
gamma omega CANCELLed: zeta
theta示例输出:
alpha
beta
delta
gamma omega
theta发布于 2016-11-30 23:23:16
弄明白了。我将评论它,以帮助任何有这个问题的人。我喜欢你通常能有多紧凑的功能,但这件作品确实需要比我想要的多几行。如果有人能把它降到更低的程度,并且让它仍然有效,请告诉我!
^L::
ClipBoard := ClipString(ClipBoard, "Canceled: ", "`n",2) ;This is the function call here.
;The first parameter is the string to do stuff to, the second is what to cut out of the
;string, and the third parameter is how far after that piece to cut, so if you wrote
;Canceled: thenawholebunchofstuffthena newline, it'd remove all of it except for the
;newline. The third parameter is which mode to put ClipString to.
Return
ClipString(lString, aMarker, bMarker, Mode := 0) ;already explained above.
;Mode defaults to zero because I call the zero mode a lot.
{
If (Mode = 0) ;Mode Zero returns the ONLY the section from the original string
;between aMarker and bMarker.
Return SubStr(lString, 1, InStr(lString, aMarker)-StrLen(aMarker)) . SubStr(lString, InStr(lString, bMarker)+StrLen(bMarker))
Else If (Mode = 1) ;Mode One returns the original string with the section between aMarker
;and bMarker removed.
Return SubStr(SubStr(lString, 1, InStr(lString, bMarker)+StrLen(bMarker)-1), InStr(lString, aMarker))
Else If (Mode = 2) ;Mode Two returns the original string with all instances of aMarker
;to bMarker removed. I.E. Every occurrence of aMarker will be removed to bMarker.
{
aString := lString
StringReplace, aString, aString, %aMarker%, %aMarker%, UseErrorLevel ;Count how many
;instances of aMarker are in the original string.
CanCnt := Errorlevel ;actual count of # of aMarkers
Loop, %CanCnt% ;loop as many times as there are aMarkers
{
aString := SubStr(aString, 1, InStr(aString, aMarker)-1) . SubStr(SubStr(aString, InStr(aString, aMarker)), InStr(SubStr(aString, InStr(aString, aMarker)), bMarker)-1)
;this is a tad complicated. The first part before the concatenate takes the string, and
;keeps from the start point to the first aMarker. The concatenate adds the substring of the
;substring between aMarker and the end of the string, and the location of the substring in
;aString from the occurrence of aMarker to one position before the start of bMarker.
;An easier way to read this would be to replace "SubStr(aString, InStr(aString, aMarker))
;with a variable like bString. It shortens it up quite a bit.
}
Return aString
}
}https://stackoverflow.com/questions/40898812
复制相似问题