如果最后一个单词是“FOUND”,则匹配文件位置。 [英] Match File Location if last word is "FOUND"
问题描述
你好我很难找到一个正常的表达式来找到正确的字符串,如果单词FOUND在它的末尾我想在比赛前返回任何东西。
这里是我试图排序的字符串示例。
C:\ Users \Admin1 \Desktop\eicar.com:Eicar -Test-Signature FOUND
C:\ Users \Admin1 \Desktop\\\
ew process run code.txt:OK
C:\ Users \Admin1 \Desktop \Super-Charger.lnk:好的
C:\ Users \Admin1 \Desktop \Thumbs.db:OK
在第一个字符串中,我想获得文件位置和文件名,如此。
C:\ Users \Admin1 \Desktop \ eicar.com
我希望有一些东西在比赛前显示所有东西,这样我就可以指定正则表达式找到FOUND这个词并排除name仅显示文件路径。
这是我能找到的最接近我要找的东西
(?< path>。+)(?< = FOUND)
这将返回基于单词FOUND的正确文件路径,但我需要剪切字符串Eicar-Test-Signature FOUND
提前感谢您的任何帮助可以提供
欢呼!
拿起一份Expresso,其他 [ ^ ]。您可能需要指定从行的开头查找所有内容,以便它拾取单行的文本而不是从文本的开头到第一次出现FOUND的所有内容。
Hello I am stumped with a regular expression needed to find the correct string if the word FOUND is at the end of it I want to return anything before the match.
here is an example of the strings I am trying to sort through.
C:\Users\Admin1\Desktop\eicar.com: Eicar-Test-Signature FOUND
C:\Users\Admin1\Desktop\new process run code.txt: OK
C:\Users\Admin1\Desktop\Super-Charger.lnk: OK
C:\Users\Admin1\Desktop\Thumbs.db: OK
In the first string I want to get just the file location and filename like so.
C:\Users\Admin1\Desktop\eicar.com
I was hoping that there was someway to show everything before a match so that I can specify the regular expression to find the word "FOUND" and exclude the name to only show the file path.
This is the closest I can get to what I am looking for
(?<path>.+)(?<=FOUND)
this returns the correct file path based on the word FOUND but I need to cut the string Eicar-Test-Signature FOUND
Thank you in advance for any help you can provide
cheers!
Pick up a copy of Expresso, here[^]. You would probably need to specify that you're look for everything from the beginning of the line so it picks up the text of a single line and not EVERYTHING form the beginning of the text to the first occurance of "FOUND".
这篇关于如果最后一个单词是“FOUND”,则匹配文件位置。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!