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
4 answers

Vim: substitution in a range that is less than a line

Let's say I have the following line of code: something:somethingElse:anotherThing:woahYetAnotherThing And I want to replace each : with a ; except the first one, such that the line looks like…
Will
  • 4,241
  • 4
  • 39
  • 48
6
votes
4 answers

Regex for replacing

with

tag?

I need to replace all:

content

with

content

in a string of content. Basically i just want to replace the "p" with a "h2". This is what i have so…
qwerty
  • 5,166
  • 17
  • 56
  • 77

6
votes
5 answers

T-SQL, Remove space in string

I have two strings in SQL and the REPLACE function only works on one of them, why is that? Example 1: SELECT REPLACE('18 286.74', ' ', '') Example 2: SELECT REPLACE('z z', ' ', '') Example 1's output is still "18 286.74" whereas Example 2's…
StevenMcD
  • 17,262
  • 11
  • 42
  • 54
6
votes
1 answer

Sublime Text 2 RegEx replace n with n+1

Using RegEx search and replace with Sublime Text 2, how can I replace my pattern matches (n) with n+1? And if there is no way to do this with search and replace, is there another easy way to do it? My RegEx pattern is ^(\d{1,4})\n, and I'd like to…
BenjaminRH
  • 11,974
  • 7
  • 49
  • 76
6
votes
4 answers

Regexp-replace: Multiple replacements within a match

I'm converting our MVC3 project to use T4MVC. And I would like to replace java-script includes to work with T4MVC as well. So I need to replace "~/Scripts/DataTables/TableTools/TableTools.min.js" "~/Scripts/jquery-ui-1.8.24.min.js" Into…
trailmax
  • 34,305
  • 22
  • 140
  • 234
6
votes
5 answers

Find string and replace line in linux

I'd like to do the following, but I can't seem to find an elegant way to do it. I have a text file that looks like this: ..more values stuff = 23 volume = -15 autostart = 12 more values.. Now the "volume" value may change, depending on the…
jliu83
  • 1,553
  • 5
  • 18
  • 23
6
votes
4 answers

Split a text to add a new line every n characters taking care of spaces

Common problem when writing text for alert and confirm dialogs: number of characters to type before adding a newline character. Some browsers auto-break at one point, others at others. So you are left guessing. Useful snippet is a Javascript…
Matt Campbell
  • 1,967
  • 1
  • 22
  • 34
6
votes
2 answers

Odd JavasScript string replace behavior with $&

With the following code: var x = 'foo'; console.log(x.replace(x, "\\$&"));​ The output is '\foo', as shown here: http://jsfiddle.net/mPKEx/ Why isn't it '\\$&"? I am replacing all of x with "\$&" which is just a plan old string so why is…
asutherland
  • 2,849
  • 4
  • 32
  • 50
6
votes
3 answers

PostgreSQL - Replace HTML Entities

I have just set about the task of stripping out HTML entities from our database, as we do a lot of crawling and some of the crawlers didn't do this at input time :( So I started writing a bunch of queries that look like; UPDATE nodes SET…
lynks
  • 5,599
  • 6
  • 23
  • 42
6
votes
3 answers

top.location.replace creates history item in Safari/Chrome

At this point we have a photogallery which uses hashvalues to determine which picture is currently showed to the user, and to support sending the page to a friend and such. Something like: http://url/photos/#photo-4 When we have loaded the…
Jan Jongboom
  • 26,598
  • 9
  • 83
  • 120
6
votes
1 answer

Replace the MS Outlook html source string using regex?

I have an application which reads the source html and downloads all the attachments of an email. This works fine except for the fact that Microsoft Outlook has some weird source value, for example...
michael
  • 14,844
  • 28
  • 89
  • 177
6
votes
6 answers

JavaScript replace() Method: remove empty space just at the end and at the beginning of the string

Possible Duplicate: How do I trim a string in javascript? By using replace method in javascript I am trying to remove the empty space between the start and the end of a string: Here my code: Any idea how should I achive the result? input -> " …
6
votes
0 answers

how to replace line feeds / carriage returns when pasting into an input element (like google)

I want line breaks to be replaced with spaces when a paste operation is done on an input (text) element. For example if the following text is pasted into google search: foo bar it pastes as: foo bar By default, text input elements will stop at the…
nn8
  • 61
  • 1
  • 2
6
votes
2 answers

Vim Search and Replace Efficiency

Often I want to search and replace in vim like this: :%s//_foo/g Is there a way to make this syntax more efficient so that I can reference in the replace value? I'm thinking it would be something…
AJ.
  • 27,586
  • 18
  • 84
  • 94
6
votes
5 answers

I need to match or replace an asterisk * in a batch environmental variable using only native Windows commands. Is this possible?

I'm trying to remove an asterisk from an environmental variable string, but can't seem to do it. I'm creating an m3u file based around search strings, so for instance I if I want to make an m3u file containing every song with the word love in it, I…
James K
  • 4,005
  • 4
  • 20
  • 28
1 2 3
99
100