Skip to content

Commit

Permalink
Fixed case where findfirst(!isletter, atomname) could be nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
brainandforce committed Oct 18, 2023
1 parent 182b7bb commit b9c1d69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/atoms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ NamedAtom("Cl1", 17)
"""
function NamedAtom(atomname::AbstractString)
# Strip any non-letter symbols from the input string
symbol = atomname[begin:findfirst(!isletter, atomname) - 1]
x = findfirst(!isletter, atomname)
symbol = isnothing(x) ? atomname : atomname[begin:x-1]
return NamedAtom(atomname, get(ELEMENT_LOOKUP, symbol, 0))
end

Expand Down

0 comments on commit b9c1d69

Please sign in to comment.