Skip to content

Instantly share code, notes, and snippets.

@roulupen
Created December 13, 2012 03:12
Show Gist options
  • Save roulupen/4273732 to your computer and use it in GitHub Desktop.
Save roulupen/4273732 to your computer and use it in GitHub Desktop.
<cfscript>
request.inputString = "RajaRamMohamRoy";
request.outputString = rEReplace(request.inputString, "([a-z])([A-Z])", "\1 \2", "ALL");
writeOutput("<b>Input String:</b>" & request.inputString & "<br/>");
writeOutput("<b>Output String:</b>" & request.outputString & "<br/>");
/*
Here regular expression we have used is "([a-z])([A-Z])"
then replacing that matching pattern with "\1 \2". Which means we are searching for a string
which lower case and upper case letter consecutively. Like aA or bC.
Then we are using regular expresson back refrencing trick to add a space between these two matching pattern.
( #Match and Capture pattern 1
[a-z] #must be a lower case alphabet
) #End of pattern 1
( #Match and Capture pattern 2
[A-Z] #must be a upper case alphabet
) # End of pattern 2
*/
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment