How do I find and replace all occurrences (in all files) in Visual Studio Code?

I’m using Visual Studio Code 1.8, and this feature is available. But it’s a little tricky to understand at first, and (at the time of writing) the docs don’t explain clearly how to use it, so here’s how it works, step by step: Invoke Replace in Files (under the Edit menu, or with shortcut Ctrl+Shift+H) … Read more

How can I remove a character from a string using JavaScript?

var mystring = “crt/r2002_2″; mystring = mystring.replace(‘/r’,”https://stackoverflow.com/”); 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, “https://stackoverflow.com/”); EDIT: Since everyone’s having so much fun here and user1293504 doesn’t seem to be … Read more

Python string.replace regular expression [duplicate]

str.replace() v2|v3 does not recognize regular expressions. To perform a substitution using a regular expression, use re.sub() v2|v3. For example: import re line = re.sub( r”(?i)^.*interfaceOpDataFile.*$”, “interfaceOpDataFile %s” % fileIn, line ) In a loop, it would be better to compile the regular expression first: import re regex = re.compile(r”^.*interfaceOpDataFile.*$”, re.IGNORECASE) for line in some_file: … Read more

MySQL string replace

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 How to find and replace text in a MySQL database

Remove a fixed prefix/suffix from a string in Bash

$ prefix=”hell” $ suffix=”ld” $ string=”hello-world” $ foo=${string#”$prefix”} $ foo=${foo%”$suffix”} $ echo “${foo}” o-wor This is documented in the Shell Parameter Expansion section of the manual: ${parameter#word} ${parameter##word} The word is expanded to produce a pattern and matched according to the rules described below (see Pattern Matching). If the pattern matches the beginning of the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)