Languages
[Edit]
EN

JavaScript - remove prefix from string

3 points
Created by:
Adnaan-Robin
724

In this article, we would like to show you how to remove prefix from string in JavaScript.

Quick solution:

 

Practical examples

Edit

1. String slice()

Edit

In this example, we use String slice() method to omit the first two letters from the text.

 

2. String substring()

Edit

In this example, we use String substring() method to omit the first two letters from the text.

 

3. String replace() with regular expression

Edit

In this example, we use String replace() method with a regular expression to replace the first two letters (AB) with an empty string.

 

References

Edit
  1. String.prototype.slice() - JavaScript | MDN
  2. String.prototype.substring() - JavaScript | MDN
  3. String.prototype.replace() - JavaScript | MDN
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.

Cross technology - remove prefix from string

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