Q:

How do I find text between two words and export it to txt.file

I have a CSV file which contains many lines and I want to take the text between <STR_0.005_Long>, and µm,5.000µm.
Example line from the CSV:

Straightness(Up/Down) <STR_0.005_Long>,4.444µm,5.000µm,,Pass,‌​2.476µm,1.968µm,25,0‌​.566µm,0.720µm 

This is the script that I am trying to write:
$arr = @()
$path = "C:\Users\georgi\Desktop\5\test.csv"
$pattern = "(?<=.*<STR_0.005_Long>,)\w+?(?=µm,5.000µm*)"
$Text = Get-Content $path
$Text.GetType() | Format-Table -AutoSize

$Text[14] | Foreach {
    if ([Regex]::IsMatch($_, $pattern)) {
        $arr += [Regex]::Match($_, $pattern)
        Out-File C:\Users\georgi\Desktop\5\test.txt -Append
    }
}
$arr | Foreach {$_.Value} | Out-File C:\Users\georgi\Desktop\5\test.txt -Append

A:

Use a Where-Object filter with your regular expression and simply output the match to the output file:
Get-Content $path |
    Where-Object { $_ -match $pattern } |
    ForEach-Object { $matches[0] } |
    Out-File 'C:\Users\georgi\Desktop\5\test.txt'

Of course, since you have a CSV, you could simply use Import-Csv and export the value of that particular column:
Import-Csv $path | Select-Object -Expand 'column_name' |
    Out-File 'C:\Users\georgi\Desktop\5\test.txt'

Replace column_name with the actual name of the column. If the CSV doesn't have a column header you can specify one via the -Header parameter:
Import-Csv $path -Header 'col1','col2','col3',... |
    Select-Object -Expand 'col2' |
    Out-File 'C:\Users\georgi\Desktop\5\test.txt'

