But the output from this drops the capital letter and I cant find any other method then unicode.IsUpper which will tell me if a letter is upper case.
Any ideas? Any help greatly appreciated?
Rémy Oudompheng
unread,
Feb 17, 2013, 11:24:01 AM2/17/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ollie Castle, golan...@googlegroups.com
Write it by hand:
controllerName := "ApiHeartRateController"
var words []string
l := 0
for s := controllerName; s != ""; s = s[l:] {
l = strings.IndexFunc(s[1:], unicode.IsUpper) + 1
if l <= 0 {
l = len(s)
}
words = append(words, s[:l])
}
Rémy.
minux
unread,
Feb 17, 2013, 11:23:40 AM2/17/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ollie Castle, golan...@googlegroups.com
using unicode.IsUpper is suitable, but strings.FieldsFunc is not.
because it will drop the field separator.
you need to use strings.IndexFunc to implement your own function for this.
Oliver Castle
unread,
Feb 17, 2013, 11:31:50 AM2/17/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rémy Oudompheng, golan...@googlegroups.com
Perfect, Thanks
Just gave me the knock to work out what I was doing wrong.