I have a file containing several thousand lines of text. I need to extract some data from it, but the data I need always contains 57 characters to the left and 37 characters from the end. The bit that I need (in the middle) has a different length.
eg. 20141126_this_piece_of_text_needs_to_be_removed<b>this_needs_to_be_kept</b>this_also_needs_to_be_removed
So far I have received:
SELECT-STRING -path path_to_logfile.log -pattern "20141126.*<b>" | FOREACH{$_.Line} | FOREACH{ $_.substring(57) }
This eliminates the text at the beginning of the line, but I donβt see how to get rid of the text from the end.
I tried:
$_.subString(0,-37) $_.subString(-37)
but they did not work
Is there any way to get rid of the last x characters?
source share