Questions tagged [replace]

Replacing is the action of searching a string for a sub-string and replacing it with a different string.

Replacing is the action of searching a string (the haystack) for a sub-string (the needle) and replacing it with a different string.

for example, replacing all 'l' within 'Hello' with 'y', would result in 'Heyyo'.

27903 questions
6
votes
1 answer

Find and replace text in multiple Photoshop files?

Let us say I have six Photoshop files: 1.psd, 2.psd, ..., 6.psd. All of these files contain the word "LoremIpsum" in random text layers, within each document. Is there a way I can search for "LoremIpsum" in all documents and replace it with "Dolor…
Malasorte
  • 1,153
  • 7
  • 21
  • 45
6
votes
1 answer

How to escape the REPLACEMENT in a perl substitution?

How do you completely escape the REPLACEMENT part of a perl subsitution with the s// operator? \Q and \E do not work as, shown below: For context, this comes up when using perl to do big recursive search and replace operations driven from a bash…
wjl
  • 7,519
  • 2
  • 32
  • 41
6
votes
4 answers

How to find and replace items not preceded or followed by specific characters with sed?

How can I restrict find and replace to replace items, but not if the character immediately before it is "A", "B", or "C" or the character immediately after it is "X", "Y", or "Z". E.g. given these input lines, if "cat" is to be replaced with…
Village
  • 22,513
  • 46
  • 122
  • 163
6
votes
5 answers

Replace multiple characters from string without using any nested replace functions

I have an equation stored in my table. I am fetching one equation at a time and want to replace all the operators with any other character. Input String: (N_100-(6858)*(6858)*N_100/0_2)%N_35 Operators or patterns: (+, -, *, /, %, (, )) Replacement…
Saharsh Shah
  • 28,687
  • 8
  • 48
  • 83
6
votes
2 answers

MySQL: Update every second row string

I need to be able to update every even (2, 4, 6, etc) row string within the image column ... the name will end with an extension .png and I want to insert some text before the .jpg So from MyImage.png to MyImage-Small.png Then I need to be able to…
dcolumbus
  • 9,596
  • 26
  • 100
  • 165
6
votes
1 answer

Replace special character in htaccess

I changed my forum from kunena to phpbb3. Problem is that my old forum (that is indexed in google) has special characters in urls. I want to keep my urls, so old link works with new forum - but only when special characters are replace with normal…
user2757017
  • 97
  • 1
  • 1
  • 5
6
votes
3 answers

How to wrap a group of words with tags, JavaScript Replace Regular Expressions

I am trying to wrap some words with HTML tags, for that I am using regular expressions. I am almost there: This is my regexp /((apple|banana|cherry|orange)\b\s?)+/gi and this is my replacement: $& which works perfectly for my example…
ploink
  • 110
  • 1
  • 7
6
votes
2 answers

Remove Excess Middle Spaces in Name - SQL

I've got a data-set of people's names but the problem is I imagine when some people were typing in their names they hit the spacebar a few times too many b/c now we have this: Notice how in the name column there're some names like John_Doe,…
Joshua
  • 287
  • 1
  • 2
  • 12
6
votes
1 answer

MySQL remove final part of a string after specific character

I need to remove the last part of a string in a column where I have a field named "path" that looks like: images/prop/images/2034/22399_2034.JPG I need everything after the last "/" to be deleted, in order to have images/prop/images/2034/ instead…
ol30cean0
  • 481
  • 4
  • 8
  • 18
6
votes
4 answers

Is it more common/standard to compare uppercase or lowercase?

I'm in my first six months of programming on the job and I'm still getting a feeling for standards and best practices. When performing string or char comparison, is it more common to use ToUpper to compare uppercase characters or ToLower for…
FLGMwt
  • 706
  • 4
  • 18
6
votes
4 answers

Can you construct a RegEx to replace unwanted characters with the underscore?

I'm trying to write a string 'clean-up' function that allows only alphanumeric characters, plus a few others, such as the underscore, period and the minus (dash) character. Currently our function uses straight char iteration of the source string,…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
6
votes
1 answer

Eclipse: How to increase find/replace history?

The find/replace dialog shows last 8 entries. The dialog is shown via Ctrl+F. I want to increase the number of entries shown in the history of the "find" and the "replace with" input field. I have to search and replace several strings and regular…
leonardo12
  • 398
  • 1
  • 7
  • 18
6
votes
2 answers

grep and sed with spaces in filenames

Currently, I have grep -irl $schema $WORKDIR/ | xargs sed -i 's/'"$schema"'/EXI1/gI' which doesn't work for filenames with spaces. Any ideas, how to search and replace recursively for all files? Thanks
rojanu
  • 1,592
  • 5
  • 20
  • 34
6
votes
2 answers

Convert java string to string compatible with a regex in replaceAll

Is there a library or any easy way to convert a string and make sure its compatible as a regex to look for and replace in another string. So if the string is "$money" it would get converted to "\$money". I tried using StringEscapeUtil.escape but it…
Kevin Colin
  • 347
  • 3
  • 4
  • 10
6
votes
2 answers

Javascript replace() only replaces first match

Hello see the jsfiddle here : http://jsfiddle.net/moolood/jU9QY/ var toto = 'bien_address_1=&bien_cp_1=&bien_ville_1='; var tata = toto.replace('&','
'); $('#test').append(tata); Why Jquery in my exemple only found one '&' and replace it?
user367864
  • 283
  • 2
  • 5
  • 11