First time here? Check out the FAQ!

Jordan Smart's profile - activity

2019-03-07 09:05:18 -0500 received badge Student (source)
2019-03-07 09:05:16 -0500 marked best answer String Methods in Regex Find and Replace

I'm trying to convert between variable naming conventions, from:

exampleVariable​

to:

example_variable​

I can find the relevant variables with the regex search "([a-z])([A-Z])", and use "\1_\2" to convert to "example_Variable", but to convert to the desired convention using re.sub() would require something like:

re.sub('([a-z])([A-Z])',lambda match: match.group(1)+"_"+match.group(2).lower(),'exampleVariable')​

However, simply placing the inline function in Wing's replace line doesn't achieve the desired effect. Is there an alternative way to accomplish what I'm looking to do?

2018-03-09 15:01:00 -0500 commented answer String Methods in Regex Find and Replace

Thanks, that'll work great!

2018-03-09 14:01:00 -0500 asked a question String Methods in Regex Find and Replace

String Methods in Regex Find and Replace I'm trying to convert between variable naming conventions, from: exampleVariabl