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

python: find and replace numbers < 1 in text file

I'm pretty new to Python programming and would appreciate some help to a problem I have... Basically I have multiple text files which contain velocity values as such: 0.259515E+03 0.235095E+03 0.208262E+03 0.230223E+03 0.267333E+03 0.217889E+03…
hjp
  • 63
  • 1
  • 3
6
votes
3 answers

SQL Server: Replace characters different than a char in a string using no temporary table

I have a NVARCHAR(10) column in a table. It can store any type of UNICODE strings. I want to replace every char which is different than '1' with '0'. Let's say I have the string '012345C18*'. I should get '0100000100'. I managed to do it using a…
darkdante
  • 707
  • 1
  • 17
  • 36
6
votes
3 answers

replace with NA

I have a data frame containing entries; It appears that these values are not treated as NA since is.na returns FALSE. I would like to convert these values to NA but could not find the way.
user34771
  • 455
  • 1
  • 4
  • 15
6
votes
6 answers

jQuery - Read More / Read Less. How to replace text?

HTML: Read More jQuery: // Slide Up Slide Down $('.show_hide').toggle(function(){ $(this).text().replace("Read More", "Read Less"); $('.' +…
William
  • 421
  • 3
  • 6
  • 17
6
votes
7 answers

regex uppercase to lowercase

Is it possible to transform regexp pattern match to lowercase? var pattern:RegExp; var str:String = "HI guys"; pattern = /([A-Z]+)/g; str = str.replace(pattern, thisShouldBeLowerCase); Output should look like this: "hi guys"
luccio
  • 485
  • 1
  • 6
  • 24
6
votes
5 answers

Replace a whole line in a txt file

I'am new to Python 3 and could really use a little help. I have a txt file containing: InstallPrompt= DisplayLicense= FinishMessage= TargetName=D:\somewhere FriendlyName=something I have a python script that in the end, should change just two…
user302935
  • 407
  • 3
  • 6
  • 11
6
votes
3 answers

Replace references to a type/namespace using Mono.Cecil

Background (unnecessary, confusing, only for the curious) I'm using the free version of Unity3D for Mobile and it doesn't allow me to use the System.Net.Sockets namespace on mobile devices. The problem is that I'm using a compiled .dll library…
user837703
6
votes
1 answer

Is there a way to use regular expressions in the replacement string in re.sub() in Python?

In Python in the re module there is the following function: re.sub(pattern, repl, string, count=0, flags=0) – Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. If the…
user3745189
  • 521
  • 1
  • 7
  • 17
6
votes
5 answers

Replace last occurrence of character in string

I've got the following string : 01/01/2014 blbalbalbalba blabla/blabla I would like to replace the last slash with a space, and keep the first 2 slashes in the date. The closest thing I have come up with was this kind of thing : PS E:\> [regex]…
Bluz
  • 5,980
  • 11
  • 32
  • 40
6
votes
3 answers

Replace only last occurrence of match in a string in VBA

I have a string like this "C://Documents/TestUser/WWW/Help/Files/Move_Help.txt" and have to replace Move_Help.txt with Move_Job.txt I am using the below code in VBA EXCEL str = "C://Documents/TestUser/WWW/Help/Files/Move_Help.txt" rlpStr =…
Isaac G Sivaa
  • 1,289
  • 4
  • 15
  • 32
6
votes
3 answers

Replace string value with '0' when string is empty

I'm taking a value from a textbox and converting it to decimal. But, the textbox value could be empty. So, how could I handle empty strings from the textbox? Unfortunately I have around 50 textboxes to deal with, so answers like 'check for null with…
ARB
  • 285
  • 1
  • 6
  • 17
6
votes
3 answers

jQuery: replace() in html()

How can I replace html parts with replace()? JS: var e = $("div"), fix = e.html().replace("google.com", "duckduckgo.com"); e.html(fix); I guess html() is not working the same as…
Martin
  • 2,007
  • 6
  • 28
  • 44
6
votes
3 answers

How do I strip quotes from an input box using PHP?

I have this: I want to strip quotes from user input so that if someone enters something like: "This is my title" it wont mess up my code. I tried this and…
Babak
  • 279
  • 1
  • 7
  • 16
6
votes
2 answers

Maxima: how to replace common subexpressions with symbols

Suppose I have an expression like (actually mine is much more complex, thousands of characters) expr:a+b*c+b*c*d; and I want to replace an internal sub-expression with a symbol (useful to avoid recomputation of common subexpressions), say k in…
mmj
  • 5,514
  • 2
  • 44
  • 51
6
votes
1 answer

SQLAlchemy: how to perform regexp_replace on column values

I am trying to do the equivalent of cast(regexp_replace(entry.page_title,'.*::: ','') AS INT) using SQLAlchemy. I've seen that you can use hybrid properties to perform functions on ORM-mapped classes. I've tried the following but I can't really…
hello-klol
  • 735
  • 10
  • 20