我有大量的文本数据,从中我可以到达特定的部分。具体部分如下图:
Caption = "Universal Plug and Play Device Host"
CheckPoint = 0
CreationClassName = "Win32_Service"
Description = "Provides support to host Universal Plug and Play devices."
DesktopInteract = FALSE
DisplayName = "Universal Plug and Play Device Host"
ErrorControl = "Normal"
ExitCode = 1077
Name = "upnphost"
PathName = "C:\\WINDOWS\\system32\\svchost.exe -k LocalService"
ProcessId = 0
ServiceSpecificExitCode = 0
ServiceType = "Share Process"
Started = FALSE
StartMode = "Disabled"
StartName = "NT AUTHORITY\\LocalService"
State = "Stopped"
Status = "OK"
SystemCreationClassName = "Win32_ComputerSystem"
SystemName = "KYAKKALA-WXP"
TagId = 0
WaitHint = 0
我需要将文本分开并存储成组。
我尝试使用以下正则表达式:
String REGEX ="(Caption)\\s=.*?(VMware USB.*)\"\\;\\n((?:(\\w+)\\s+=\\s+(.*)\\n) {1,21}?)";
通过应用正则表达式,我进入 gp1“caption”、gp2“vmware usb 仲裁服务”、gp3“waithint”和 gp4“0”。我需要获取 21 行的所有数据,
但它只获取第一行和最后一行。