I see a lot of “grab last word”, “grab first/last X characters” or “grab lines that contain XXX” however I’ve been unable to find a solution here for my problem.
For example, my text file contains thousands of lines like: [0000001] item_title apple_juice_2L_concentrate 0x000581 [0000002] item_description 98%_reconstituted_apple_juice 0x00585 [0000003] item_title orange_juice_2L_natural 0x000679 [0000004] item_description 100%_fresh_squeeze_orange_juice 0x00985 [0000005] item_title apple_juice_1L_natural 0x000429 [0000006] item_description 100%_natural_apple_juice_cloudy 0x00587
how would I achieve a printout like this while cutting out the junk i dont want like the [0000001], item_title and the 0x000581 apple_juice_2L_concentrate apple_juice_1L_natural
As Sankhadip suggests, regex is your friend for this type of problem. You should read through Microsoft’s regex documentation page. For this particular instance, you can solve the problem easily with -split.
[quote quote=181746]As Sankhadip suggests, regex is your friend for this type of problem. You should read through Microsoft’s regex documentation page. For this particular instance, you can solve the problem easily with -split. Here’s an example, modifying your code: