Search Results

Search found 1731 results on 70 pages for 'replacing'.

Page 8/70 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • vim regex for replacing spaces within quotes

    - by vikram-bhat
    I have text in the follwing format: ERR_OUT_OF_MEM, "ERR OUT OF MEM" ERR_SOMETHING_BAD, "ERR SOMETHING BAD" I want to replace all spaces in the text which are within quotes with underscores: ERR_OUT_OF_MEM, "ERR_OUT_OF_MEM" ERR_SOMETHING_BAD, "ERR_SOMETHING_BAD" The best regex I could come up with is: \("\w\+\)\@<= (there's a space at the end of that) but this only finds the first space in each quoted string, and I would need to repeat this multiple times to get the desired effect. Any way to do it in one shot? Thanks!

    Read the article

  • Replacing text after node

    - by Andrew
    I am trying to remove the "Hide this data" from this XML which is proceeded with the qualifier type="noView" <element version="Local"> <qualifier name="Public" type="View" /> Good to go </element> <element version="Local"> <qualifier name="Public" type="noView" /> Hide this data </element> I am using this XSL <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="qualifier"> <xsl:call-template name="replace-noview" /> </xsl:template> <xsl:template name="replace-noview"> <xsl:param name="text" select="@type"/> <xsl:choose> <xsl:when test="contains($text, 'noView')"> <xsl:copy-of select="."/> <xsl:text>DELETED</xsl:text> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> The output I'm getting is <element identifier="ContactName" version="Local"> <qualifier name="Public" type="View" /> Good to go </element> <element identifier="ContactName" version="Local"> <qualifier name="Public" type="noView" />DELETED Hide this data </element> I am matching the "noView" attribute and can add the "DELETED" text. However I need to remove the follow "Hide this data" text. The output I would like is <element identifier="ContactName" version="Local"> <qualifier name="Public" type="View" /> Good to go </element> <element identifier="ContactName" version="Local"> <qualifier name="Public" type="noView" /> DELETED </element>

    Read the article

  • Vim: Replacing a line with another one yanked before

    - by duddle
    At least once per day i have the following situation: A: This line should also replace line X ... X: This is line should be replaced I believe that I don't perform that task efficiently. What I do: Go to line A: AG Yank line A: yy Go to line X: XG Paste line A: P Move to old line: j Delete old line: dd This has the additional disadvantage that line X is now in the default register, which is annoying if I find another line that should be replaced with A. Yanking to and pasting from an additional register ("ayy, "aP) makes this simple task even less efficient. My Questions: Did I miss a built-in Vim command to replace a line yanked before? If not, how can I bind my own command that leaves (or restores) the yanked line in the default register?

    Read the article

  • Replacing elements within a string in R

    - by Maureen
    Hi, I have a row in a data frame in R that is made up of sequences of undetermined length of 0s 1s and 2s as characters. So "01", "010", "201", "102", "00012"... things like this. I'd like to find a way to determine if the last character in the string is NUMERICALLY the largest. It's important that I keep the row in the data frame as characters for other purposes. So basically I want to take substr(x, nchar(x), nchar(x)) and determine if it, as a number, is the largest of the numbers in the character string. I'm super lost as to how to do this, since I'm not all that familiar with regular expressions and I have to back and forth between treating elements as characters and numbers. Thanks in advance. ~Maureen

    Read the article

  • Regex Replacing only whole matches

    - by Leen Balsters
    I am trying to replace a bunch of strings in files. The strings are stored in a datatable along with the new string value. string contents = File.ReadAllText(file); foreach (DataRow dr in FolderRenames.Rows) { contents = Regex.Replace(contents, dr["find"].ToString(), dr["replace"].ToString()); File.SetAttributes(file, FileAttributes.Normal); File.WriteAllText(file, contents); } The strings look like this _-uUa, -_uU, _-Ha etc. The problem that I am having is when for example this string "_uU" will also overwrite "_-uUa" so the replacement would look like "newvaluea" Is there a way to tell regex to look at the next character after the found string and make sure it is not an alphanumeric character? I hope it is clear what I am trying to do here. Here is some sample data: private function _-0iX(arg1:flash.events.Event):void { if (arg1.type == flash.events.Event.RESIZE) { if (this._-2GU) { this._-yu(this._-2GU); } } return; } The next characters could be ;, (, ), dot, comma, space, :, etc.

    Read the article

  • replacing data.frame element-wise operations with data.table (that used rowname)

    - by Harold
    So lets say I have the following data.frames: df1 <- data.frame(y = 1:10, z = rnorm(10), row.names = letters[1:10]) df2 <- data.frame(y = c(rep(2, 5), rep(5, 5)), z = rnorm(10), row.names = letters[1:10]) And perhaps the "equivalent" data.tables: dt1 <- data.table(x = rownames(df1), df1, key = 'x') dt2 <- data.table(x = rownames(df2), df2, key = 'x') If I want to do element-wise operations between df1 and df2, they look something like dfRes <- df1 / df2 And rownames() is preserved: R> head(dfRes) y z a 0.5 3.1405463 b 1.0 1.2925200 c 1.5 1.4137930 d 2.0 -0.5532855 e 2.5 -0.0998303 f 1.2 -1.6236294 My poor understanding of data.table says the same operation should look like this: dtRes <- dt1[, !'x', with = F] / dt2[, !'x', with = F] dtRes[, x := dt1[,x,]] setkey(dtRes, x) (setkey optional) Is there a more data.table-esque way of doing this? As a slightly related aside, more generally, I would have other columns such as factors in each data.table and I would like to omit those columns while doing the element-wise operations, but still have them in the result. Does this make sense? Thanks!

    Read the article

  • Replacing text with a link in jQuery

    - by Eli
    I'm trying to replace a small part of text in a large HTML document with my own element which I create on the fly. The text may be a huge bulk of text, html, images, what-ever, and what I want is to find the first (or all) the position of a certain string, and replace it with an element that I create using $('< span'). Using simple text.replace('the string', $('< span')); doesn't do the trick (I'm left with [object Object] and not the actual < span that I want. The reason I don't just inject direct HTML is because I want to retain all the binds that are related to the object I'm creating. and doing a replace with a custom ID, and then attaching binds to the ID after the HTML has been altered, seems a bit dirty. Thanks for the help! :)

    Read the article

  • replacing variables in output in php

    - by Thorpe Obazee
    Right now I have this code. <?php error_reporting(E_ALL); require_once('content_config.php'); function callback($buffer) { // replace all the apples with oranges foreach ($config as $key => $value) { $buffer = str_replace($key, $value, $buffer); } return $buffer; } ob_start("callback"); ?> some content <?php ob_end_flush(); ?> in the content_config.php file: $config['SiteName'] = 'MySiteName'; $config['SiteAuthor'] = 'thatGuy'; What I want to do is that I want to replace the placeholders that with the key of the config array with its value. Right now, it doesn't work :(

    Read the article

  • is there a better way of replacing duplicates in a list (python)

    - by myeu2
    Given a list: l1: ['a', 'b', 'c', 'a', 'a', 'b'] output: ['a', 'b', 'c', 'a'_1, 'a'_2, 'b'_1 ] I created the following code to get the output. Its messyyy.. for index in range(len(l1)): counter = 1 list_of_duplicates_for_item = [dup_index for dup_index, item in enumerate(l1) if item == l1[index] and l1.count(l1[index]) > 1] for dup_index in list_of_duplicates_for_item[1:]: l1[dup_index] = l1[dup_index] + '_' + str(counter) counter = counter + 1 Is there a more pythonic way of doing this? I couldnt find anything on the web.

    Read the article

  • Replacing backslashes in Python strings

    - by user323659
    I have some code to encrypt some strings in Python. Encrypted text is used as a parameter in some urls, but after encrypting, there comes backslashes in string and I cannot use single backslash in urllib2.urlopen. I cannot replace single backslash with double. For example: print cipherText '\t3-@\xab7+\xc7\x93H\xdc\xd1\x13G\xe1\xfb' print cipherText.replace('\\','\\\\') '\t3-@\xab7+\xc7\x93H\xdc\xd1\x13G\xe1\xfb' Also putting r in front of \ in replace statement did not worked. All I want to do is calling that kind of url: http://awebsite.me/main?param="\t3-@\xab7+\xc7\x93H\xdc\xd1\x13G\xe1\xfb" And also this url can be successfully called: http://awebsite.me/main?param="\\t3-@\\xab7+\\xc7\\x93H\\xdc\\xd1\\x13G\\xe1\\xfb" Any idea will be appreciated.

    Read the article

  • jQuery replacing an image inside a .net datalist

    - by user359409
    (submit said I was trying to post an image so I've changed image everywhere to ix I am trying to get jQuery to replace an ix inside a datalist. The original ix is the thumbnail ix of a product on a category page. The small ix I am clicking on are swatch ix for the different colors of a product. I can get it to work using a div tag around the ix tag inside the ItemTemplate. I don't need to use a div tag if I can get the imagesx to swap- I was just using it because that is sample code I found and it works for the first product in the category. <asp:HyperLink ID="ProductNav" runat="server" NavigateUrl='<%#Eval("NavigateUrl") %>'> <div id="ladiv" runat="server"> <asp:Ixx runat="server" ID="ProdThumb" /> </div> </asp:HyperLink> <asp:PlaceHolder ID="phSwatches" runat="server"></asp:PlaceHolder> The ProdThumb ix is added from the code behind and the swatches are added from the code behind swatches.Controls.Add(new LiteralControl("<table><tr>")); foreach(OptionChoice optionChoice in option.Choices) { string swatchThumbnail = string.Format("<ix ID=\"{0}\" src=\"{1}\" border=\"0\" class=\"{2}\" />","swatch" + optionChoice.OptionChoiceId.ToString(), ResolveUrl(optionChoice.ThumbnailUrl),"imgthumb"); swatches.Controls.Add(new LiteralControl("<td>")); swatches.Controls.Add(new LiteralControl(swatchThumbnail)); swatches.Controls.Add(new LiteralControl("</td>")); } swatches.Controls.Add(new LiteralControl("</tr></table>")); prodThumb.IxUrl = product.ThumbnailUrl; prodThumb.AlternateText = product.ThumbnailAltText; prodThumb.CssClass = "Thumbnail"; The jQuery is: $(function() { $("ix.imgthumb").click(function(e) { var t = $(this); var newImg = ''; $('#ladiv') .html($(newImg) ); }); }); </script> Both images are named similar, except the swatch contains "sws" and the larger one is the some only with "swl". I have spent several days searching but am not able to get it to work. If I try something like $("#<%=ladiv.ClientID %") the code can't find it. I appreciate any help.

    Read the article

  • replacing a path with sed

    - by compie
    How can I use sed to replace this line char * path_list_[1] = { "/some/random/path" }; with this line char * path_list_[2] = { "lib/foo", "lib/bar" }; in a file named source.c Notes: * The path is really random. * Your solution should only change this line in source.c * I'm only interested in a sed oneliner. You can use this Python regex as a starting point: text = re.sub('static const char \* path_list_\[1\] = \{ "[^"]*" \};', 'static const char * path_list_[2] = { "lib/sun", "lib/matlab" };', text)

    Read the article

  • Replacing div html() by echoing PHP - how to?

    - by Jared
    Hello, I have a multiple product elements that get their class and ID from PHP: $product1["codename"] = "product-1"; $product1["short"] = "Great Product 1"; $product2["codename"] = "product-2"; $product2["short"] = "Great Product 2"; <div class="leftMenuProductButton" id="'. $product1["codename"].'" >'. $product1["short"].'</div> <div class="leftMenuProductButton" id="'. $product2["codename"].'" >'. $product2["short"].'</div> These display as: <div class="leftMenuProductButton" id="product-1" > Great Product 1</div> <div class="leftMenuProductButton" id="product-2" > Great Product 2</div> In the page, I have an element that I want to replace the HTML: <div id="productPopupTop"> //Replace this content </div> Using jquery, I have tried the following: $( '.leftMenuProductButton' ).hover ( function () { var swapNAME = $(this).attr("id"); //gets the ID, #product-1, #product-2 etc. This works. $("#productPopupTop").html(' <? echo $' + swapNAME + '["short"] ?>'); //This is supposed to get something like <? echo $product-1["short"] ?> This doesn't appear to work. }, function () { //this is just here for later }); If I try to do an alert('<? echo $' + swapNAME + '["short"] ?>'); it will literally display something like <? echo $product-1["short"] ?> Please note that both the Javascript and the PHP are externally linked in a PHP file (index.php <<< (js.js, products.php) QUESTION: How do I replace the HTML() of #productPopupTop with the ["short"] of a product? If I should use Ajax, how would I code this?

    Read the article

  • Vim: replacing start and end of a visual char, line or block

    - by gattu marrudu
    I am trying to find a shortcut to place a custom comment sequence on my code, e.g.: /* start of comment blah end of comment /**/ (it is easier to void the comment by just adding a / to the beginning) I would like to do this in Vim by selecting a visual line, block or char and adding '/' characters at the beginning of the block and '/*/' at the end, plus newlines. After selecting some lines (Shift-V) I tried this: '<,'>s/\(.*\)/\/*\r\1\r\/**\// But it adds the comment chars at EACH newline. How can I only apply the substitution at the beginning and end of the selected range? Thanks gm

    Read the article

  • CSS Doozie: Replacing BG Image on SELECT dropdown

    - by ToiletOverflow
    I need to be able to change the background-image property of a SELECT drop-down using JavaScript/CSS. We have been able to accomplish this in Firefox, but it doesn't appear to be supported at all in IE. From what I've read, IE won't support this. But I'm wondering if there's anything else I could try. Does anyone here have any recommendations?

    Read the article

  • Replacing whitespace with sed in a CSV (to use w/ postgres copy command)

    - by Wells
    I iterate through a collection of CSV files in bash, running: iconv --from-code=ISO-8859-1 --to-code=UTF-8 ${FILE} | \ sed -e 's/\"//g' | \ sed -e 's/, /,/g' \ > ${FILE}.utf8 Running iconv to fix UTF-8 characters, then the first sed call removes the double quote characters, and the final sed call is supposed to remove leading and trailing whitespace around the commas. HOWEVER, I still have a line like this in the saved file: FALSE,,,, 2.40,, The COPY command in postgres is kind of dumb, so it thinks " 2.40" is not valid syntax for a numeric value. Where am I going wrong w/ my processing of the CSV file? Thanks!

    Read the article

  • Replacing certain words with links to definitions using Javascript

    - by adharris
    I am trying to create a glossary system which will get a list of common words and their definitions via ajax, then replace any occurrence of that word in certain elements (those with the useGlossary class) with a link to the full definition and provide a short definition on mouse hover. The way I am doing it works, but for large pages it takes 30-40 seconds, during which the page hangs. I would like to either decrease the time it takes to do the replacement or make it so that the replacement is running in the background without hanging the page. I am using jquery for most of the javascript, and Qtip for the mouse hover. Here is my existing slow code: $(document).ready(function () { $.get("fetchGlossary.cfm", null, glossCallback, "json"); }); function glossCallback(data) { $(".useGlossary").each(function() { var $this = $(this); for (var i in data) { $this.html($this.html().replace(new RegExp("\\b" + data[i].term + "\\b", "gi"), function(m) {return makeLink(m, data[i].def);})); } $this.find("a.glossary").qtip({ style: { name: 'blue', tip: true } }) }); } function makeLink(m, def) { return "<a class='glossary glossary" + m.replace(/\s/gi, "").toUpperCase() + "' href='reference/glossary.cfm' title='" + def + "'>" + m + "</a>"; } Thanks for any feedback/suggestions!

    Read the article

  • Replacing special characters by null

    - by madheena
    Hi, Is there any function to replace the special characters by null in informatica if we used replacestr function, i think we should specify all special characters as follows replacestr(input,'!','~','@','#','$','%','^','&','*',null) But we dont know what are teh special characters will be coming as input. can u please let me know that which function will be suitable.

    Read the article

  • Replace always replacing null values

    - by Mike
    Why does left(FIELD, replace(nullif(charindex('-', FIELD), 0), null, len(FIELD))) always return null? The idea behind the query is that if charindex() returns 0, then convert the results into null, then convert the null into the length of the field. So if '-' does not exist, show the whole string. For some reason it makes every row equal null. Thank you.

    Read the article

  • replacing elements horizontally and vertically in a 2D array

    - by wello horld
    the code below ask for the user's input for the 2D array size and prints out something like this: (say an 18x6 grid) .................. .................. .................. .................. .................. .................. code starts here: #include <stdio.h> #define MAX 10 int main() { char grid[MAX][MAX]; int i,j,row,col; printf("Please enter your grid size: "); scanf("%d %d", &row, &col); for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { grid[i][j] = '.'; printf("%c ", grid[i][j]); } printf("\n"); } return 0; } I now ask the user for a string, then ask them where to put it for example: Please enter grid size: 18 6 Please enter word: Hello Please enter location: 0 0 Output: Hello............. .................. .................. .................. .................. .................. Please enter location: 3 4 Output: .................. .................. .................. ..Hello........... .................. .................. program just keeps going. Any thoughts on how to modify the code for this? PS: Vertical seems way hard, but I want to start on horizontal first to have something to work on.

    Read the article

  • replacing values in formated file with python

    - by froggy
    I have a string see attached file like that and i would like to modify it using a function Giving section name parameter name and value to set Also in case i want to modify several parameters for a same section how can i have position in file to avoid scanning x time for a same section and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question an and other to pass my question d other to pass my question and other to pass my question and other to pass my question and other to pass my questionand other to pass my question and other to pass my question

    Read the article

  • Recursively looping through a drive and replacing illegal characters

    - by yeahumok
    Hi I have to create an app that drills into a specific drive, reads all file names and replaces illegal SharePoint characters with underscores. The illegal characters I am referring to are: ~ # % & * {} / \ | : <> ? - "" Can someone provide either a link to code or code itself on how to do this? I am VERY new to C# and need all the help i can possibly get. I have researched code on recursively drilling through a drive but i am not sure how to put the character replace and the recursive looping together. Please help!

    Read the article

  • Replacing/Adding resources (icon) programmatically in c#?

    - by reverendo
    I am trying to replace (or add in the case it doesn't exists) icons from .exe files using c#. So far I got this: string filename = "c:\\test.exe"; IntPtr hResource = BeginUpdateResource(filename, true); if (hResource.ToInt32() == 0) throw new Exception("File Not Found"); byte[] ico = System.IO.File.ReadAllBytes("C:\\icon.ico"); IntPtr unmanagedPointer = Marshal.AllocHGlobal(ico.Length); Marshal.Copy(ico, 0, unmanagedPointer, ico.Length); if (UpdateResource(hResource, "Icon", "1", 1033, unmanagedPointer, Convert.ToUInt32(ico.Length)) != false) { MessageBox.Show("Updated"); EndUpdateResource(hResource, false); } Marshal.FreeHGlobal(unmanagedPointer); "Icon", "1", 1033 <- I got this data by opening test.exe with Resource Hacker. I do get the messagebox "Updated", and if I open the resulting exe in Resource Hacker the resource gets replaced but the icon doesn't appear, its just empty. Also that code wont replace, the type "Icon" in the resource, it will delete everything and add that "Icon" and if I use BeginUpdateResource(path, false); it will not replace it neither but it will add ANOTHER "Icon". Where can I find an example to replace/add the icon using c# disregarding the name the resource use for the icon or if the resource doesn't exist?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >