dirask
ENPL1
HomeCommunities
IT Knowledge
SnippetsWikifor CodeQuestions
Inspiration
NewsFindings
Snippets
Browse Code Snippets

js regex remove everything after certain character (excluding)

JavaScript
[Edit]
+
0
-
0

js regex remove everything after certain character (excluding)

DexterDexter
660
1 2 3 4 5 6 7
const regex = /(:).+$/; // match ':' character and everything after it const text = 'Example text: removed part.'; const result = text.replace(regex, '$1'); // remove everything after ':' character console.log(result); // 'Example text:'
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Donate with PayPal button
Direct link
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.
= +
Features
Home
Snippets
Wiki
Questions
Findings
About
About & Contact
Service Terms
Cookies Policy
Privacy Policy
GDPR Privacy Policy
Policies
Other
Code Formatters
Funny Generators
Post Lists
Social Links
© 2022 dirask - created with passion