replace

Remove part of a string from a variable jquery

I'm trying to take the id of a mouseover and strip out part of the ID, to leave me with just the core text I need to act on. My mouseover will return an id such as "nevadaActiveArea", but I need to manipulate that string down to just "nevada". All the searches I've run speak to how to do this on the contents of some element, but I just ...

PHP Regex Replace with Backreference modified by functions

I want to replace the class with the div text like this : This: <div class="grid-flags" >FOO</div> Becomes: <div class="iconFoo" ></div> So the class is changed to "icon". ucfirst(strtolower(FOO)) and the text is removed Test HTML <div class="grid-flags" >FOO</div> Pattern '/class=\"grid-flags\" \>(FOO|BAR|BAZ)/e' Replacement ...

How to perform link rewriting with a .NET Regex?

I need to use C# Regex to do a link rewrite for html pages and I need to replace the links enclosed with quotes (") with my own ones. Say for example, I need to replace the following "slashdot.org/index.rss" into "MY_OWN_LINK" However, the actual link can be of the form "//slashdot.org/index.rss" or "/slashdot.org/index.rss" whe...

file manipulation and find a word and tricky replace

I have file something like this hostname ser1-xyz myuser name passwd secret group 1234 hostname ser2-xyz myuser name passwd secret group 2345 I need to find the line first appearance of host named "ser1-xyz" and modify it as "ser1" and increment it's the group value by 1 So that final file looks like : hostname ser1...

PHP regular expression needed to replace line breaks, but only those between quotes

Hey everyone, our customer supplied us with XML data that needs to be processed using PHP. They chose to abuse attributes by using them for big chunks of text (containing line breaks). The XML parser replaces the line breaks with spaces to make the XML W3 compliant. To make sure we do not lose our line breaks, I want to read in the fi...

What is the correct syntax for replacing two characters at once in ColdFusion?

Hello, I'm trying to replace two special characters using the replace function in ColdFusion: <cfset MyQuery = "/Attribute One\/Attribute Two\/Attribute Three\"> <cfset MyString = Replace(MyQuery, "/", "<li>", "ALL")> <ul> <cfoutput>#MyString#</cfoutput> </ul> This works well, but I need to correctly close my li tags. I tried adding ...

changing time format with preg replace in php

i m just wondering if we can do this with preg replace like if there's time like 1h 38 min can change to 98 mins 2h 20 min can change to 140 mins or just suggest me any other random function to this is simpler way thanks ...

VIM: how to add search/replace command to vimrc and map to a shortcut

I have two search/replace commands that I find myself running in vim fairly often to clean up html code so I can copy/paste it online. The commands are: :%s!<!\&lt;!g :%s!>!\&gt;!g I wanted a way I could map both of these commands to be run together ... I did some searching for how to use the :map commands in vimrc, however, I can't ...

Java String.replaceFirst() that takes a "starting from" argument

I need to replace a word in a string looking like "duh duh something else duh". I only need to replace the second "duh", but the first and the last ones need to stay untouched, so replace() and replaceFirst() don't work. Is there a method like replaceFirst(String regex, String replacement, int offset) that would replace the first occurre...

Bad Word Filter, how to combine with URL Replace

Hi, I have two scripts - javascript and php.. this cleans the url <script type="text/javascript"> $(document).ready(function() { $('.search-form').submit(function() { window.location.href = "/file_"+ $('.search-form input:text').val() + ".html"; return false; }); }); </script> this is the bad word filter <?...

LINQ to XML, replace child nodes but keep state

I've got the following XML passed as an IQueryable to a method, i.e. XML: <body> <p>Some Text</p> <p>Some Text</p> <pullquote>This is pullquote</pullquote> <p>Some Text</p> <p>Some Text</p> <body> Method: public static string CreateSection(IQueryable<XElement> section) { var bodySection = from b in articleSection.Des...

Oracle MERGE does not INSERT

I have this simple example I can't seems to get working : MERGE INTO mytable mt USING dual ON (mt.id = 'AAA' ) WHEN MATCHED THEN UPDATE SET mt.name = 'updated' WHEN NOT MATCHED THEN INSERT (mt.id , mt.name ) VALUES ('AAA', 'Gooood' ); If a 'AAA' record exists in the table, it is updated successfully. But if does no...

How can I make use of Visual Studio's regular expression to replace multiple lines of code?

Is it possible to make use of Visual Studio 2005/2008 "Find" and "Replace" functionality along with regular expression to replace multiple lines of already coded C# code into a single line of code? Note that Visual Studio's "Find" and "Replace" regular expression syntax differs from .NET Framework. ...

Powershell, how many replacements did you make?

I need to know how many replacements are made by Powershell when using either the -replace operator or Replace() method. Or, if that's not possible, if it made any replacements at all. For example, in Perl, because the substitution operation returns the number of replacements made, and zero is false while non-zero is true in a boolean ...

Replacing quotation marks in Javascript?

For a web app I'm making, I'm going to be getting text strings coming in, occasionally which contain quotation marks. Because I am then going to be document.writing the string, they need to be changed either into apostrophes or escaped. How would I do that, because when I try it doesn't seem to work, specifically I think because the st...

question about javascript string's replace method

Hi guys, I know that I can pass a string as the second parameter to the JavaScript string object's replace method. In this case I can use $` and $' to reference the left/right part text of a successful match. Now my question is, If I pass a callback function as the second parameter, how can I get the same information? I want to use this...

Prototype find class and replace text

Hi Guys, I am using the prototype framework [requirement by platform] and I am trying to find a ID and replace some text in the ID so that it disappears. The HTML looks like: <div id="top"> <a href="/login">login</a> | <a href="/register">register</a> </div> The problem is I don't want the " | " to appear in the ID "top". So I guess...

Find and Replace Text with Prototype

I am new to Prototype and was wondering how to simply "find" some text in a class/ID and "replace" this text. My html is like this: <div id="test"> <a href="/test">test</a> <a href="/test2">test2</a> <a href="/test3">test3</a> <a href="/test4">test4</a> </div> And I am trying to replace the "test" in between the <a> tags for ...

How do you replace double quotes with a blank space in Java?

For example: "I don't like these "double" quotes" and I want the output to be I don't like these double quotes ...

PHP: Changing or padding an array's key names

I have the following array: $person = array('first_name' => 'Fred', 'last_name' => 'Flintstone'); I want to change/pad the keys so the array will end up as (note extra colons): $person = array('::first_name::' => 'Fred', '::last_name::' => 'Flintstone'); For some reason I'm drawing a blank on the simplest way to do this ...