Hi all,
i am extracting the data from a webpage, storing the output in a 3-column data table. The third column contains an url.
i then run the following powershell script to extract part of the url, to obtain what it is the codenumber of the document.
I try to trim, to remove the newline chars, to check if the last charachter is a real charachter (see below).
$url = "%Lista[LIndex]['url']%"
$protocollo = $url.Substring($url.IndexOf("Protocollo=") + 11)
$parte1 = $protocollo.Substring(7, 11).Trim()
$parte2 = $protocollo.Substring(18, 7).Trim()
$result = "$parte1 - $parte2".Trim()
$cuValue = $result
$cleaned = $cuValue.TrimEnd()
while (-not [char]::IsLetterOrDigit($cleaned[-1]) -and $cleaned.Length -gt 0) {
$cleaned = $cleaned.Substring(0, $cleaned.Length - 1)
}
$cleaned += ".pdf"
Write-Output $cleaned
However, the resulting variable always consists of 2 rows:
This creates issue when e.g. i want to save the document, as PAD will return an illegal name error.
To overcome this issue i've added the extension directly in the script, but it means that i need to create as many variables as the use i want to do with the original variable, which is quite inefficient.
Do you have any hints?
thank you in advance!

Report
All responses (
Answers (