Snake to Camel Case Utility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfparam name="form.snake_case" default=""> | |
<cfparam name="form.camel_case" default=""> | |
<cfparam name="form.upper_camel_case" default=""> | |
<cfscript> | |
if (len(form.snake_case)) { | |
form.camel_case = REReplace(form.snake_case, "_([a-zA-Z])", "\u\1", "all"); | |
form.upper_camel_case = REReplace(form.camel_case, "\b([a-zA-Z]+)", "\u\1", "all"); | |
} | |
</cfscript> | |
<cfoutput> | |
<form method="POST"> | |
<h3>Snake Case</h3> | |
<textarea name="snake_case" cols="60" rows="10">#form.snake_case#</textarea> | |
<h3>Camel Case</h3> | |
<textarea name="camel_case" cols="60" rows="10">#form.camel_case#</textarea> | |
<h3>Upper Camel Case</h3> | |
<textarea name="upper_camel_case" cols="60" rows="10">#form.upper_camel_case#</textarea> | |
<button>Submit</button> | |
</form></cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment