Languages
[Edit]
EN

TypeScript - make first letter of string uppercase

0 points
Created by:
evangeline
420

In this article, we're going to have a look at how to capitalize the first letter of a string in TypeScript.

Quick solution:

Note: presented below example is not universal. Read all article to find better universal solutions.

Output:

ES6 version

Edit

Output:

 

1. Capital letter of first word examples

Edit

Presented approaches find the first letter in string and transform it to upper case. To find the beginning of the first world regular expression is used in the below examples.

1.1. String replace method with regular expression example

Edit

This section shows how to capitalize first word occurrence with replace method.

Output:

1.2. String search method with regular expression example

Edit

This section shows how to capitalize first word occurrence with search method.

Output:

Alternative titles

  1. How to uppercase first letter of string in TypeScript?
  2. How to capitalize first world of string in TypeScript?
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join