String manipulating / Read PDF Text


#1

Any idea how i can get two values from text to variables using String manipulating. Heres the text:


KELA tilaus 4.5% -1.64 24% -0.39 -2.03
KELA tilaus 2% -0,27 24% - 0.06 -0.33
Tilitetään 11.82
Toimittajanumero

Numbers what i need are at the end of line: “-2.03” and “-0.33”

-mikko


#2

Hi,

If it’s always the last value separated by spaces, you can use Split and take the last string.
This might also depend on what you are going to do with these values.

Here is an example:
Assume “str” is variable with text

array = str.Trim.Split(System.Environment.Newline(0)).Select(Function(s) If(s.ToString.Trim<>" ",s.ToString.Trim.Split(" "c).Last,s))

I don’t know if this is the most ideal for what you need but maybe it will help strike some other ideas.
This example splits by Newline, then runs a LINQ through each line and only stores the .Last string in the line.

You can also simply just run a ForEach through str.Trim.Split(System.Environment.Newline(0)), and pull the last item (line.ToString.Trim.Split(" "c).Last) in the loop as you process the line.

Regards.