Regex capitalize first letter every word, also after a special character like a dash

+1 for word boundaries, and here is a comparable Javascript solution. This accounts for possessives, as well: var re = /(\b[a-z](?!\s))/g; var s = “fort collins, croton-on-hudson, harper’s ferry, coeur d’alene, o’fallon”; s = s.replace(re, function(x){return x.toUpperCase();}); console.log(s); // “Fort Collins, Croton-On-Hudson, Harper’s Ferry, Coeur D’Alene, O’Fallon”

How to autocapitalize the first character in an input field in AngularJS?

Yes, you need to define a directive and define your own parser function: myApp.directive(‘capitalizeFirst’, function($parse) { return { require: ‘ngModel’, link: function(scope, element, attrs, modelCtrl) { var capitalize = function(inputValue) { if (inputValue === undefined) { inputValue=””; } var capitalized = inputValue.charAt(0).toUpperCase() + inputValue.substring(1); if(capitalized !== inputValue) { modelCtrl.$setViewValue(capitalized); modelCtrl.$render(); } return capitalized; } modelCtrl.$parsers.push(capitalize); … Read more

Check if first letter of word is a capital letter

update Updating with what i think is the most valid approach nowadays. You can use a Unicode property escapes Regular expression if the support suits you. In this case you can use the General category property for Uppercase Letter Lu. function isUppercase(word){ return /^\p{Lu}/u.test( word ); } older answers var word = “Someword”; console.log( word[0] … Read more

Regular expression for checking if capital letters are found consecutively in a string

Whenever one writes [A-Z] or [a-z], one explicitly commits to processing nothing but 7-bit ASCII data from the 1960s. If that’s really ok, then fine. But if it’s not ok, then Unicode character properties exist to help you with handling modern character data. There are three cases in Unicode, not two. Furthermore, you also have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)