There are a number of ways to do this. I’m not sure what you have learnt at this point.
You can use regex:
([_\-\*]) matches _, - or *. \ is and escape for the special regex characters. This is group 1
?<= Is positive lookahead, so it will look for _, - or * before the ([a-z]) part.
([a-z]) means match any character that is from a to z lower case (only 1 character). This is group 2
newValue = match.group()
newValue = newValue.replace(match.group(1), "")
newValue = newValue.replace(match.group(2), match.group(2).upper())
pattern = "([_\-\*])(?<=[_\-\*])([a-z])"
example1 = "get_element_by_name"
formattedExample1 = re.sub(pattern, matchToUpper, example1)
example2 = "set*name"
formattedExample2 = re.sub(pattern, matchToUpper, example2)
Regex probably isn’t the expected answer though. What have you learnt at this point? Loops? Splitting strings and arrays? Because it can be done with both of them too.
Edit2: Just noticed I miss read what the output should be. You haven’t said what to do with double __/–/** so this will not do anything special with them and will leave the extra one and still capitalise the following character.