这是我的示例文本和正则表达式
Regex101
我想在数字、类别、“此服务器的特定角色或功能是什么?”、“服务器主机名:”等之后匹配文本。但是,如果使用的文本发生变化,我现在使用的方法将无法正常工作。我希望这是动态的,这样它可以跳过尽可能多的行/字符数,以达到下一个匹配。
我目前正在使用以下正则表达式:
Number\:\s(?<Number>\d+)[\r\n]Category\:\s(?<Category>.*).*[\r\n].*[\r\n].*[\r\n]What\sis\sthe\sspecific\srole\sor\sfunction\sof\sthis\sserver\?\:\s(?<Function>.*).*[\r\n].*[\r\n].*[\r\n].*[\r\n].*[\r\n].*[\r\n].*[\r\n].*[\r\n].*[\r\n].*[\r\n]Server\sHostname\:\s(?<Hostname>.*).*[\r\n]Server\sAllegiance\:\s(?<Domain>.*).*[\r\n].*[\r\n]Physical\sLocation\:\s(?<Location>.*).*[\r\n].*[\r\n].*[\r\n].*[\r\n].*[\r\n]Local\sAdministrators\:\s+([\w\s]+)[\r\n].*[\r\n].*[\r\n]Task\sDescription\:\s(?<Task>.*)
我知道,我知道,这很难看!