var mystring = "crt/r2002_2";
mystring = mystring.replace('/r','/');

will replace /r with / using String.prototype.replace.

Alternatively you could use regex with a global flag (as suggested by Erik Reppen & Sagar Gala, below) to replace all occurrences with

mystring = mystring.replace(/\/r/g, '/');

EDIT: Since everyone's having so much fun here and user1293504 doesn't seem to be coming back any time soon to answer clarifying questions, here's a method to remove the Nth character from a string:

String.prototype.removeCharAt = function (i) {
    var tmp = this.split(''); // convert to an array
    tmp.splice(i - 1 , 1); // remove 1 element from the array (adjusting for non-zero-indexed counts)
    return tmp.join(''); // reconstruct the string
}

console.log("crt/r2002_2".removeCharAt(4));

Since user1293504 used the normal count instead of a zero-indexed count, we've got to remove 1 from the index, if you wish to use this to replicate how charAt works do not subtract 1 from the index on the 3rd line and use tmp.splice(i, 1) instead.

Answer from JKirchartz on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › replace
String.prototype.replace() - JavaScript | MDN
April 12, 2026 - The replace() method of String values returns a new string with one, some, or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function called for each match. If pattern is a string, only the first occurrence ...
Discussions

How to Remove ([]"") using Javascript Regex
You just need to escape them. To represent a [ character you'd write \[ '[("MT-1","MT-2","MT-3","MT-4")] '.replace(/[\(\)\[\]"]/g, '') Or you could just specify the characters you want to keep and replace anything BUT those, which makes this a little more readable: '[("MT-1","MT-2","MT-3","MT-4")] '.replace(/[^a-zA-Z0-9,-]/g, '') More on reddit.com
🌐 r/learnjavascript
5
3
January 12, 2022
Remove string after certain character
Hello I would like to know the formula i can use in the set a variable module to remove characters after a certain character e.g. character to remove is / input: google.com/1234abcd output: google.com Please can someone help me with this? More on community.make.com
🌐 community.make.com
3
1
June 28, 2024
Ways to remove spaces from a string using JavaScript
Thanks for sharing. I just did a performance test. The average time it takes each function (10,000 runs) to remove the spaces from a text with 1800 words/spaces in it. replaceAll: 0.08585000002384185 miliseconds replace: 0.10449000005722046 miliseconds splitAndJoin: 0.2322219943579563 miliseconds filterAndJoin: 1.1504000001549721 miliseconds Seems like replaceAll is the fastest and filterAndJoin is the slowest. More on reddit.com
🌐 r/learnjavascript
33
204
January 11, 2023
Is there a cleaner way to delete characters from a string?
s = s[:i] + s[i+1:] More on reddit.com
🌐 r/pythontips
18
0
March 6, 2023
🌐
Axure Forums
forum.axure.com › t › remove-all-characters-from-string-from-certain-point › 66559
Remove all characters from string from certain point - Axure RP 9 - Axure Forums
January 15, 2020 - If there is no second argument then the end of the string is used–so the returned slice will contain everything up to and including the last character in the string. Keep in mind strings start at 0 (zero), so in your username, “BNARob” the position (or in javascript lingo, the index ) of ‘B’ is 0. If I wanted to get only the first 3 chars from your username I would use string.slice(0, 3)
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-remove-a-character-from-string-in-javascript
Remove a Character From String in JavaScript - GeeksforGeeks
February 25, 2026 - One of the most common methods to remove a character from a string is by using the replace() method.
🌐
Reddit
reddit.com › r/learnjavascript › how to remove ([]"") using javascript regex
r/learnjavascript on Reddit: How to Remove ([]"") using Javascript Regex
January 12, 2022 -

Hi all,

I'm passing a string that looks like this:

[("MT-1","MT-2","MT-3","MT-4")] 

I want to write a Javascript function which converts the string to this:

MT-1,MT-2,MT-3,MT-4

Essentially I want to remove ([]"") characters. Is there a way to do this using Regex commands?
I looked at this link but couldn't find anything about removing special characters.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet

My code so far:

var x = "[("MT-1","MT-2","MT-3","MT-4")]"; 
x = xxx.replace(/[^0-9]+/g, "");
🌐
CoreUI
coreui.io › blog › how-to-remove-the-last-character-from-a-string-in-javascript
How to Remove the Last Character from a String in JavaScript · CoreUI
June 23, 2024 - In this example, substring(0, str.length - 1) removes the last character by using the length of the string minus one as the end index. The replace() method can also remove the last character by using a regular expression.
Find elsewhere
🌐
Stackademic
blog.stackademic.com › javascript-how-to-remove-a-character-from-a-string-398e81f13617
JavaScript: How to Remove a Character From a String | by Alex Zelinsky | Stackademic
September 23, 2024 - 💡 Learn how to check for an empty object in JavaScript: ... The replace() method is one of the most straightforward ways to remove a character from a string.
🌐
Sentry
sentry.io › sentry answers › javascript › how do i remove/chop/slice/trim off the last character in a string using javascript?
How do I remove/chop/slice/trim off the last character in a string using Javascript? | Sentry
Strings in JavaScript are immutable, so whenever we want to manipulate one, we must create a new string with our desired changes. Therefore, to remove the last character of a string, we must create a new string that excludes it.
🌐
Quora
quora.com › How-do-you-remove-all-occurrences-of-a-character-from-a-string-in-JavaScript
How to remove all occurrences of a character from a string in JavaScript - Quora
Answer (1 of 2): In JavaScript there is no character type, it’s all just strings. So, you would just replace the substring consisting of your one character with an empty string, effectively removing it from the original string. To replace all occurrences of a substring in another string, ...
🌐
LeetCode
leetcode.com › problems › remove-all-adjacent-duplicates-in-string
Remove All Adjacent Duplicates In String - LeetCode
Can you solve this real interview question? Remove All Adjacent Duplicates In String - You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them. We repeatedly make duplicate removals on s until ...
🌐
FastAPI
fastapi.tiangolo.com › tutorial › query-params-str-validations
Query Parameters and String Validations - FastAPI
We are going to enforce that even though q is optional, whenever it is provided, its length doesn't exceed 50 characters. ... from typing import Annotated from fastapi import FastAPI, Query app = FastAPI() @app.get("/items/") async def read_items(q: Annotated[str | None, Query(max_length=50)] = None): results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} if q: results.update({"q": q}) return results
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-remove-character-from-string
How to Remove Characters from a String in Python | DigitalOcean
May 31, 2026 - Use str.replace() for a single character or substring, str.translate() or str.maketrans() to drop several characters in one pass, re.sub() for pattern-based removal, and slicing when you need to remove characters at the start, end, or a fixed index. This tutorial walks through each approach ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › delete-first-character-of-a-string-in-javascript
JavaScript - Delete First Character of a String - GeeksforGeeks
Similar to slice(), substring() creates a new string starting from index 1, effectively removing the first character.
Published   July 11, 2025
🌐
Make Community
community.make.com › questions
Remove string after certain character - Questions - Make Community
June 28, 2024 - Hello I would like to know the formula i can use in the set a variable module to remove characters after a certain character e.g. character to remove is / input: google.com/1234abcd output: google.com Please can someo…
🌐
W3Schools
w3schools.com › jsref › jsref_replace.asp
JavaScript String replace() Method
cssText getPropertyPriority() getPropertyValue() item() length parentRule removeProperty() setProperty() JS Conversion ... let text = "Visit Microsoft!"; let result = text.replace("Microsoft", "W3Schools"); Try it Yourself » ... let text = "Mr Blue has a blue house and a blue car"; let result = text.replace(/blue/g, "red"); Try it Yourself » · More examples below. The replace() method searches a string for a value or a regular expression.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
3 days ago - A String object is returned, ... with the character at index m-that is, the result of this.substring(k, m + 1). This method may be used to trim whitespace (as defined above) from the beginning and end of a string. ... A string whose value is this string, with any leading and trailing white space removed, or this string ...
🌐
Text-Utils
text-utils.com › remove special characters
Remove Special Characters - Online Regex Tools | Text-Utils.com
September 6, 2025 - Keep numeric & spaces only: Remove all non-numeric & non-space characters from the text.
🌐
Code Beautify
codebeautify.org › blog › remove-special-sharacters-from-string-javascript
Remove Special Characters From String Javascript
February 22, 2024 - When working with strings in JavaScript, there might be scenarios where you need to remove special characters to sanitize or process the data. Let’s explore a simple solution to achieve this. Approach 1 : 1 2 3 4 5 6 7 8 9 10 11 function removeSpecialCharacters(inputString) { // Use a regular expression to match and replace special characters return inputString.replace(/[^\w\s]/gi, ''); } // Example usage: const originalString = "Hello!
🌐
W3Schools
w3schools.com › js › js_strings.asp
JavaScript Strings
Templates are strings enclosed ... will be chopped to "We are the so-called ". To solve this problem, you can use an backslash escape character....