UPDATE and REPLACE part of a string

I’ve got a table with two columns, ID and Value. I want to change a part of some strings in the second column. Example of Table: ID Value ——————————— 1 c:\temp\123\abc\111 2 c:\temp\123\abc\222 3 c:\temp\123\abc\333 4 c:\temp\123\abc\444 Now the 123\ in the Value string is not needed. I tried UPDATE and REPLACE: UPDATE dbo.xxx SET … Read more

MySQL string replace

I have a column containing urls (id, url): http://www.example.com/articles/updates/43 http://www.example.com/articles/updates/866 http://www.example.com/articles/updates/323 http://www.example.com/articles/updates/seo-url http://www.example.com/articles/updates/4?something=test I’d like to change the word “updates” to “news”. Is it possible to do this with a script? 6 s 6 UPDATE your_table SET your_field = REPLACE(your_field, ‘articles/updates/’, ‘articles/news/’) WHERE your_field LIKE ‘%articles/updates/%’ Now rows that were like http://www.example.com/articles/updates/43 will be http://www.example.com/articles/news/43 … Read more

Remove specific characters from a string in Python

I’m trying to remove specific characters from a string using Python. This is the code I’m using right now. Unfortunately it appears to do nothing to the string. for char in line: if char in ” ?.!/;:”: line.replace(char,”) How do I do this properly? 26 s 26 Strings in Python are immutable (can’t be changed). … Read more

How do I replace a character at a particular index in JavaScript?

I have a string, let’s say Hello world and I need to replace the char at index 3. How can I replace a char by specifying a index? var str = “hello world”; I need something like str.replaceAt(0,”h”); 27 s 27 In JavaScript, strings are immutable, which means the best you can do is to … Read more

Fastest method to replace all instances of a character in a string [duplicate]

This question already has answers here: How to replace all occurrences of a string in JavaScript (79 answers) Closed 2 years ago. The community reviewed whether to reopen this question 8 months ago and left it closed: Needs details or clarity Add details and clarify the problem by editing this post. What is the fastest … Read more