Reputation: 25
I want to extract the text between "Part Description:" and "- Installs" using R; similarly, need to extract other text - as the text is continuous not able to extract.
Sample text:
Support Queue: WW_SC GD OB V5; V5 Business: ; Local Weekend: True; Local Holiday: False; *** NOTE: This is a PARTNER device. Please follow special partner process instead of standard support chain. SupportID: 469 ********************************* ** Event and Event Attachments ** ********************************* Incident Number: 34c-48a6 OS Version: Windows Server, 2003 Event Time: 2015-07-10T00:29.7110Z Part Number: xxxxxx-001, Part Description: 1000 watt AC hot-plug power supply - Installs in the computer chassis as primary or redundant supply (800 watts at 100VAC to 1000 watts at 200VAC maximum power) - Requires 100-240VAC at 50/60Hz , RoHS Yes, CSR A Error Type: HW No attachments. Recommended Action: The power supply in Bay 2 has failed and should be replaced with spare part number xxxxxx-001.
Upvotes: 2
Views: 1168
Reputation: 21497
You could do the following:
sub(".*Part Description:(.*)Installs.*", "\\1", txt)
This substitutes the whole string by the part in between Part Description:
and Installs
. This results in: " 1000 watt AC hot-plug power supply - "
Or using stringr
you can do:
require(stringr)
str_sub(str_extract(txt, "Part Description:.*Installs"), 18, -9)
Which gives you the same result.
Upvotes: 5