Add capitalized letter after each dash in a string

php get first letter of each word
php ucwords not working
php ucfirst not working
only first letter capital in php
php capitalise string
string case in php
strtocamel php

Here is an example of what my problem is

let str = 'A-bb-cc-dd'

How do I make it so that the string will return


You can do it like this,

let str = 'A-bb-cc-dd';
let result = (str.split('-').map(e=>e.charAt(0).toUpperCase() + e.slice(1))).join('-');

PHP capitalize after dash, ucfirst() simply capitalized the first letter of the string. If you want multiple letters capitalized, you must create multiple strings. $strings = explode("  Finally, let’s talk about whether you capitalize the first word after a colon or a dash. A dash doesn’t require any extra thought regarding capitalization. You treat the first word after a dash the same way you’d treat it if it followed a comma. On the other hand, you sometimes have to make a decision about capitalization when you use a colon.

You can split by the string by - delimiter then use map to create a new array where the first character will be uppercased using toUpperCase and then use join to recreate the string

let k = 'A-bb-cc-dd';
let convertedStr = k.split('-').map((item) => {
  return item.charAt(0).toUpperCase() + item.slice(1);
How do i make it so that the string will return 'A-Bb-Cc-Dd'

ASP.NET MVC 4 Recipes: A Problem-Solution Approach, To add the connection string to the configuration file, perform the following steps: 1. The emulator uses a well-known name and key that is the same for all users. This means that no special characters (except dashes) are allowed in a container name and only lowercase letters are Uppercase letters are not allowed. First off, no. Don't capitalize after a dash unless it’s a proper noun that follows. Second—and I'm going to be pedantic here—those examples don't use proper dashes for what they're trying to convey.

You can use a JS regular expression and String.replace like so

const result = 'A-bb-cc-dd'.replace(/(^\w|-\w)/g, c => c.toUpperCase());


The London Quarterly Review, rarely subscribed himself otherwise than with the single initial capital letter C, seized a piece of paper, wrote down on it » string of words which he extracted they add this dash to every other form of punctuation, in the following manner,  No, the dash represents a pause in the sentence, which continues after the dash. Since the sentence did not end you do not capitalize "yes". For a detailed list of capitalization and other style rules you can reference this Oxford Style Guide PDF.

Use string split, map and join:

let str = 'A-bb-cc-dd';
var array = str.split("-"); //console.log(array);
var result = => {
    return current[0].toUpperCase() + current.substr(1);
var end = result.join("-");

Miss Leslie's Magazine, Always remember that every period or full stop, and every note of admiration or interrogation, must be followed by a capital letter — dashes, particularly in dialogue, frequently add much It is scarcely possible for a person who reads much to spell incorrectly, for the Seals are generally a sufficient security without a string. Then capitalize the first letter of the resulting substrings and reunite to result string. (Be careful for spaces between periods and letters, maybe split by "\. "): String result = ""; for (int i=0; i < split.length; i++) { result += Character.toUpperCase(split[i].trim()); } System.out.println(result); Should do it.

You can use a simple regex in a replace statement:

let str = 'A-bb-cc-dd'

  str.replace(/\-[a-z]/g, match => match.toUpperCase())

ucfirst - Manual, ucfirst — Make a string's first character uppercase plemieux' function did not work for me without passing the encoding to every single mb function (despite  Given the string "ThisStringHasNoSpacesButItDoesHaveCapitals" what is the best way to add spaces before the capital letters. So the end string would be "This String

Inserting Dashes between Letters in Words (Microsoft Word), Sub CapDashNames() Dim sTemp As String Dim sName As String Dim J As Text) ' Make all uppercase If Len(sTemp) > 1 Then sName = "" For J = 1 To you'​ve selected and adds a dash after each alphabetic character. Capitalization: First Word After a Colon. In British English, the first letter after a colon is capitalized only if it’s a proper noun or an acronym; in American English, the first word after a colon is sometimes capitalized if it begins a complete sentence.

The Quarterly Review, and “ changethe single initial capital letter C , which he less , ” added below them a string of words which he extracted from those substituting a dash for a period Occasionally they add this dash to every * It may be remarked , by the way  -string-iomanip Also, I would like to avoid creating any user defined functions. I understand that I will require functions such as toupper[] to convert the letters to uppercase letters, a for loop to evaluate each word of the sentence, and something like a counter to only capitalize the first letter of the word being evaluated.

freeCodeCamp Challenge Guide: Spinal Tap Case - Guide, Create a regular expression for all white spaces and underscores. charCodeAt​(i+1)<=90){ // if the next character is Uppercase, then add the "-" result+=String. It then replaces that match with the string on the right which contains a dash in  Need insert a dash in between last 4 digits in text string I have a column (TractID) that has a 10 character text string, like the following entry: 0190003164.

  • I've added an answer for you. Is that helped?
  • we're on the same track :)