Issue with findfirst on a string

I’m trying to parse a parameter file with julia. I have lines of commentary that I would like not to process . I tried :

lines = readlines(file)
	for line in lines
		if sizeof(line)>0
			nomParametre = replace(string(line[1])," "=>"")
			if findfirst(nomParametre,"#")==nothing
valeurParametre = string(line[2])

When I run this code I’m getting :

SubString{String}["# parametres "]
ERROR: LoadError: BoundsError: attempt to access 1-element Array{SubString{String},1} at index [2]

The main question is : Why the findfirst function return nothing on String “# parametres” ?

The second question is : Do I need to convert my substring in string like I m doing ? It seems totally illogical to me that substring does not have the same members as string
Thanks in advance

Hi rafeal,

Thank you for your answer but you missunderstood my question.

I know that the line “# parametres” doesn’t have a tab that is why I have the line
if findfirst(nomParametre,"#")==nothing
to avoid calling string(line[2]) on this line

My question is to know why the findfirst(nomParametre,"#") returns “nothing”
When I write “findfirst(“blabla#”,”#") it works and does not return nothing but it does on my string “nomParametre” which contains a “#”

Check the help text for findfirstpattern is the first argument:

help?> findfirst("#", "#parametre")
  findfirst(pattern::AbstractString, string::AbstractString)
  findfirst(pattern::AbstractPattern, string::String)

  Find the first occurrence of pattern in string. Equivalent to findnext(pattern, string, firstindex(s)).


  julia> findfirst("z", "Hello to the world") # returns nothing, but not printed in the REPL

  julia> findfirst("Julia", "JuliaLang")

julia> findfirst("#", "#parametre")

Thank you pfitzsed. Shame on me for a so simple solution :hugs:

I checked the find first but couldn’t get my error :see_no_evil: