string-replacement

What is the most efficient way to replace many string tokens in many files in Java?

What I want to accomplish is a tool that filters my files replacing the occurrences of strings in this format ${some.property} with a value got from a properties file (just like Maven's or Ant's file filtering feature). My first approach was to use Ant API (copy-task) or Maven Filtering component but both include many unnecessary depend...

XML field replacement in C#

ok, so, i have an xml file that looks like this: <?xml version="1.0"?> <Users> <User ID="1"> <nickname>Tom</nickname> <password>a password</password> <host>[email protected]</host> <email>anemail</email> <isloggedin>false</isloggedin> <permission>10</permission> </User> <User ID="2"> <nickname>ohai</nic...

Javascript replace doesn't work

function areaMe(area){ var barea = $('#barea').val(); if(barea.indexOf(area)!=-1){ alert ("..." + barea + "..." + area + "..."); barea.replace(area, "cu"); // remove alert ("..." + barea + "..." + area + "..."); }else{ barea+=area+' '; // inlcui } $('#barea').val(barea); } ...

Real examples of SQL injection issues for SQL Server using only a Replace as prevention?

I know that dynamic SQL queries are bad due to the SQL Injection issues (as well as performance and other issues). I also know that parameterized queries are prefered to avoid injection issues, we all know that. But my client is still very stubborn and thinks that just var UserName=Request.Form["UserName"]; UserName=UserName.Replace...

Javascript String Replace

I have a string of tags delimited by semicolons: "red; yellow; blue; green; purple" I would like to strip out all the tags that do not match a substring (case-insensitive.) For example, if I have a substring "Bl" I would like to return "blue". Any suggestions as how to best accomplish this in javascript? Specifically, I'm wonderi...

How do I perform several string replacements in one go?

I'm writing an app in C# which allows the user to perform database queries based on file names. I'm using the Regex.Replace(string, MatchEvaluator) overload to perform replacements, because I want the user to be able to have replacement strings like SELECT * FROM table WHERE record_id = trim($1) even though the DB we're using doesn't su...

Token replacement

Hey, I currently implement a replace function in the page render method which replaces commonly used strings - such as replace [cfe] with the root to the customer front end. This is because the value may be different based on the version of the site - for example the root to the image folder ([imagepath]) is /Images on development and l...

How to replace a String twice with oldValues having same text within?

I am trying to take a block of text and scan it for specific text (name) and turn it into a URL, specifically: Block of text: Chairman Joe Smith has announced a new plan to decrease expenditures by outsourcing the planning of the new dining hall. Smith states the current project managers do not have excess time to commit to this new pr...

Help Replacing Non-ASCII character in Python

I have a bunch of HTML files I downloaded using HTTPLIB2 package in Python. ' ' are showing as 'Â '. <font color="#ff0000">02/12/2004Â </font> is showing while <font color="#ff0000">02/12/2004&nbsp;</font> is the desired format. How do I replace the 'Â ' with '&nbsp;' in Python? Thanks a lot! ...

Binary version of StringReplace

I'm trying to run AnsiStrings.StringReplace on a RawByteString holding a blob of data, some of which needs to be replaced. It would work, except that inside StringReplace it converts my string to a PAnsiChar, and so the search ends up bailing out as soon as it hits the first #0 byte inside the blob. I'm looking for a routine that works...

Is there a Boyer-Moore string search and fast search and replace function and fast string count for Delphi 2010 String (UnicodeString) out there?

I need three fast-on-large-strings functions: fast search, fast search and replace, and fast count of substrings in a string. I have run into Boyer-Moore string searches in C++ and Python, but the only Delphi Boyer-Moore algorithm used to implement fast search and replace that I have found is part of the FastStrings by Peter Morris, fo...

ASP.NET StreamWriter - new line after x commas

Hey guys, I've got a JS array which is writing to a text file on the server using StreamWriter. This is the line that does it: sw.WriteLine(Request.Form["seatsArray"]); At the moment one line is being written out with the entire contents of the array on it. I want a new line to be written after every 5 commas. Example array: BN,ST,A...

Make new string from old string, C#

Input: X(P)~AK,X(MV)~AK Expected Output: P(curr=AK),MV(curr=AK) Using C#3.0 I solved by using string functions(split,then appending etc.) Looking for more niche solution(like regular expression) Thanks ...

str_ireplace() with keeping of case

Hello! How can I use str_ireplace (or something similar) to replace some text for formatting and then return it with the same caps? Example: $original="The quick red fox jumps over the lazy brown dog."; $find="thE"; print str_ireplace($find,'<b>'.$find.'</b>',$original); That will output: thE quick red fox jumps over the lazy brown...

Javascript replacement of the characters *, +, and / within a string

Alright, so I'm currently working on a simplistic manner of mimicking the function of PHP's urlencode() with JS's escape() and some string replacement. I'm purely looking at keyboard characters, so no special ASCII or Unicode characters. The problem I'm encountering is that the specific characters *, +, and / all have special meanings ...

Replacing an array in vim

I had an array in my code that's andI I used an index c[i]. I wanted to change c[i] and write g[i][j] in that place. I tried to use the command %s/c[i]/g[i][j]/g but did something unusual. How can I do such replacement in Vim? Thanks in advance. ...

Suggestions to improve a C ReplaceString function?

Hi, I've just started to get in to C programming and would appreciate criticism on my ReplaceString function. It seems pretty fast (it doesn't allocate any memory other than one malloc for the result string) but it seems awfully verbose and I know it could be done better. Example usage: printf("New string: %s\n", ReplaceString("great",...

strip span tags from string with jquery

I am wanting to take the text value of a p tag when I press enter $.keynav.enterDown = function () { var accom = $('#suggestions p.keynavon').html(); alert(accom); } This is working great but the results contain <span> and </span> tags, is there anyway I can strip those tags from the string? ...

find the text and the strip the text at a certain point

I am trying to write this funtion to grab the text value and then strip the text from after the - symbol and the - symbol itself. eg some text - is found would become some text This is what iv got so far currently it just removes the - $.keynav.enterDown = function () { var accom = $('#suggestions p.keynavon').text().r...

How to replace common words in sql column

I have a table of common words that are used in sentences (i.e. A, the, and, where, etc...) What I want to do is loop through all those words and strip them out of the descriptions that people have entered to attempt to generate common keywords or tags. But I can't use replace because replace will remove any instance of the common word ...