replace

replace values in a vector based on another vector

I would like to replace values in a vector (x) with values from another vector (y). Catch 22: The methods needs to be dynamic to accommodate different number of "levels" in vector x. For instance, consider vector x x <- sample(c(1, 2, 3, 4, 5), 100, replace = TRUE) > x [1] 2 4 1 1 3 1 1 1 1 1 2 2 5 5 4 5 5 3 4 1 2 2 3 3 3 5 1 3 4 5 5 ...

C# Regex.Replace(): getting the values

I'm parsing a BB code image tag: [img]http://imagesource.com[/img] I'm using the following Replace() function: Regex.Replace(msg, @"\[img\]([^\]]+)\[\/img\]", @"<img src=""$1"" border=""0"" />", RegexOptions.IgnoreCase); And I need to get the URL while parsing. I need to know the value of "$1". Is it possible? The Regex class so...

Java: Find and replace words/lines in a file

I have a file (more specifically, a log4j configuration file) and I want to be able to read in the file and pick out certain lines in the code and replace them. For example, within the file there is a string of text that indicates the directory it is stored in, or the level of the logger. I want to be able to replace those string of text...

string filtering on c++

given a string literal in c++ i have to remove toxic words like stupid etc by ###. Suppose i have my toxic words in an array like char[][]={"...",".."...and more...} and my string is like char str[]="......." any particular library func that could help me here. thanks in advance for help ...

Replace a empty space with "&nbsp;" using Jquery

I am looking around on the web but I am not finding anything useful. :( I am having a problem that I don't understand. I am sure that I am doing something wrong, but I don't know well the syntax of jQuery to understand what is that I am not doing right. I am using animations with JS and CSS 3, and I am having troubles with empty spaces...

How to replace the first occurrence of a regular expression in Python?

I want to replace just the first occurrence of a regular expression in a string. Is there a convenient way to do this? Thanks, ...

Is there an Objective-c regex replace with callback/C# MatchEvaluator equivalent ?

I have a C# project I'm intending to port to Objective-C. From http://stackoverflow.com/questions/422138/regular-expressions-in-an-objective-c-cocoa-application, it looks like there's a confusing variety of Regex options but I can't see anything about a way of doing a replace with callback. That is, the equivalent of the C# MatchEvaluato...

Replace unicode character

Hi there. I am trying to replace a certain character in a string with another. They are quite obscure latin characters. I want to replace character (hex) 259 with 4d9, so I tried this: str_replace("\x02\x59","\x04\xd9",$string); This didn't work. How do I go about this? ...

JavaScript: Add elements in textNode

Hi, I want to add an element to a textNode. For example: I have a function that search for a string within element's textNode. When I find it, I want to replace with a HTML element. Is there some standard for that? Thank you. ...

Replace a word in BLOB text by MySQL.

Hello! I've got a huge mysql table (called tcountriesnew) and a column (called slogen, blob type). In each of those slogen blobs I'd like to replace a word, for example: banana to apple. Unfortunately I tried to print all the rows with word banana, and it did not work. select * from tcountriesnew where slogen like '%banana%'; Please ...

How do I remove content between X and Y using preg_replace?

What would the regular expression be for removing any content between a quote, and the directory "uploads/"? Using a regexpression generator, I get this: (?<=\=")[^]+?(?=uploads/) $block_data = preg_replace('/(?<=\=")[^]+?(?=uploads/)/g','',$block_data); But seems to be removing everything :( ...

How to replace more than once?

This is my code so far: $("h1.intro:contains('|')").each(function() { $(this).html($(this).html().replace('|','</span><br /><span>')) }); This works just once, but it has to work for all of those "|"... any ideas? ...

swapping out an image when selector is clicked using jquery

Hello guys, I have an FAQ and would like to attach an image to the right of the question that tells the person to close if open and open if closed. This is what I have: $('.header-person').click(function() { $(this).next('.entry').slideToggle("fast") return false; }); I currently have the two images next to the question like...

replace the same characters with different strings

Assuming I have a string $str = "abc*efg*hij*"; and an array $arr = array("123","456","789"); Now I want to replace the *s in $str with the elements in $arr according to the positions.The first * replaced with $arr[0],the second replaced with $arr[1] etc.I check the function str_replace,though it accepts arrays as parameters but I...

Regex replace in Eclipse

I am trying to make a global search/replace in Eclipse. I have lines as follow: <MED:Student id= <MED:Course id= <MED:Marks id= <MED:Attendance id= Now I need to insert a VAL so it would become: <MED:Student VAL id= <MED:Course VAL id= <MED:Marks VAL id= <MED:Attendance VAL id= What would be the proper regular expression that woul...

Remove characters after string?

I have strings that looks like this: John Miller-Doe - Name: jdoe Jane Smith - Name: jsmith Peter Piper - Name: ppiper Bob Mackey-O'Donnell - Name: bmackeyodonnell I'm trying to remove everything after the second hyphen, so that I'm left with: John Miller-Doe Jane Smith Peter Piper Bob Mackey-O'Donnell So, basically, I'm trying to ...

Regular expression to replace line feeds with a space only if the break is not in the contents of an HTML attribute

I'm trying to write a regular expression that replaces line feeds between certain areas of a text file, but only on plain text content (i.e. excludes text inside HTML attribute contents, like href) but not having much luck past the first part. Example input: AUTHOR: Me DATE: Now CONTENT: This is an example. This is another example. <a ...

Replacing Words in TextField In Django

In django, in TextField, how to we replace, [vimeo 123456] with <iframe src="http://player.vimeo.com/video/123456" width="400" height="225" frameborder="0"></iframe> Thank you. ...

Capitalize names properly in SQL

I would like to capitalize names properly, which in this case means: The first letter is capitalized. The first letter after a space is capitalized ('Van Helsing', not 'Van helsing') The first letter after a dash is capitalized ('Johnson-Smith', not 'Johnson-smith') No other letters are capitalized. The first and last requirements ar...

ASP .NET MVC AJAX BeginForm InsertionMode.Replace Not Working well

I can see the result when entering anything in text field. The result does go to the DIV I want. However, I look at the source code for the page, I don't see the replacement element. For example, I enter 'aaaaaaaaaaaaaaaa', click submit button, I see the result as You entered aaaaaaaaaaaaaaaa; But right click to open source, I don't see...