// NewIRIFromString separates the fragment from the first part (Head), if the given value has a fragment.
// Otherwise, Fragment remains empty.
// error if val is no valid IRI. Note that most error conditions are not checked.
NewIRIFromString separates the fragment from the first part (Head), if the given value has a fragment.
Otherwise, Fragment remains empty.
error if val is no valid IRI. Note that most error conditions are not checked.
// NewIRIFromString separates the fragment from the first part ( Head ) if the given value has a fragment . // Otherwise Fragment remains empty . // error if val is no valid IRI . Note that most error conditions are not checked .
func NewIRIFromString(val string) (*IRI, error) {
	parts := strings.Split(val, "#")
	switch len(parts) {
	case 1: 
		return &IRI{Head: parts[0]}, nil
	case 2: 
		return &IRI{Head: parts[0] + "#", Fragment: parts[1]}, nil
	default:
		return nil, fmt.Errorf("invalid IRI string with multiple # (%v)", val)
	}
}
func NewIRIFromString ( val string ) ( * IRI , error ) { parts := strings . Split ( val , " " ) switch len ( parts ) { case 1 : return & IRI { Head : parts [ 0 ] } , nil case 2 : return & IRI { Head : parts [ 0 ] + " " , Fragment : parts [ 1 ] } , nil default : return nil , fmt . Errorf ( " " , val ) } }
NewIRIFromString separates the fragment from the first part (Head), if the given value has a fragment.
NewIRIFromString separates the fragment from the first part ( Head ) if the given value has a fragment .
// no "#" // had "#" : keep the # at the end of Head