How can I change "flat 3 245a HILL road" to "Flat 3 245A Hill Road" in javascript? -


when enters street address single field on form, want convert street address title case. isn't quite title case letter comes directly after string of numbers should upper case.

as example want "flat 3 245a hill road" not "flat 3 245a hill road".

i know that:

var str = "flat 3 245 hill road"; str.split(" ").map(function(i){return i[0].touppercase() + i.substring(1).to lowercase()}).join(" "); 

will convert "flat 3 245a hill road" "flat 3 245a hill road".

but want convert "flat 3 245a hill road"?

another example

it should "18b hill crescent" not "18b hill crescent"

try

str.replace(/(\d+)([a-z]+)/, function(a) { return a.touppercase(); }) 

to handle 245a


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -