julia> parse(Float64,ans[1])
200.5

On Mon, Jul 18, 2016 at 3:33 PM, Yared Melese <[email protected]> wrote:

> Thanks for quick response, it works in most cases but when the number is
> float, parse has problem as shown below
>
> How about when the number has decimal points for example
>
> exString = "Exact number 390  \n Exact qty    : +200.5 people \n Starting
> number:  5 now 16.5A_C"
> srchStr ="Exact qty    :"
> search(exString, srchStr)
> ans = exString[search(exString, srchStr)[end]+1:end] |> strip |> split
> value1= parse(string,ans[1])
>
> Thanks
> Yared
>
>
> On Monday, July 18, 2016 at 1:31:16 PM UTC-5, Yared Melese wrote:
>
>> Hello
>>
>> I was trying to parse a number from string as shown below. Would you
>> please let me know if there is easy way to get the number after
>> a specific string ? please note that the string can be variable(different)
>>
>> goal is to specify search string and put out exact number with out any
>> text before and after the number.
>>
>> The current program shown below has two faults
>> 1. on line 10, I have to manually enter starting word but cannot put a
>> variable as shown below
>> c = match(r"$srchStr[\w|\w %s%f%f|.|:|+]*", b[srchInd])
>>
>> 2. I have to only get a number, that means anything in front and behind
>> that number should be stripped off
>>
>>
>>
>> exString = "Exact number 390  \n Exact qty: +200 people \n Starting
>> number:  5 now 16.5A_C"
>> srchStr ="Exact qty:"
>> b= split(exString,"\n") # put each line to an array form
>> #find index of excact string match
>> for i in 1:length(b)
>>     if contains(b[i], srchStr) == true
>>       srchInd = i
>>     end
>>    end
>> c = match(r"$srchStr[\w|\w %s%f%f|.|:|+]*", b[srchInd])
>> d=replace(c.match, srchStr,"")
>> print(d)
>>
>

Reply via email to