Search Results

Search found 7634 results on 306 pages for 'preg replace'.

Page 2/306 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Regular Expression to replace part of URL in XML file

    - by Richie086
    I need a regular expression in Notepad++ to search/replace a string. My document (xml) has serveral thousand lines that look similar to this: <Url Source="Output/username/project/Content/Volume1VolumeName/TopicFileName.htm" /> I need to replace everything starting from Volume1 to .htm" / to replaced with X's or some other character to mask the actual file names in this file. So the resulting string would look like this after the search/replace was performed: <Url Source="Output/username/project/Content/Volume1XxxxxxXxxx/XxxxxXxxxXxxx.htm" /> I am working with confidential information that I cannot release to people outside of my company, but i need to send an example log file to a 3rd party for troubleshooting purposes. FYI the X's do not need to follow the upper/lower case after the replacement, i was just using different case X's for the hell of it :)

    Read the article

  • Multiple REPLACE function in Oracle

    - by Adnan
    I am using the REPLACE function in oracle to replace values in my string like; SELECT REPLACE('THE NEW VALUE IS #VAL1#','#VAL1#','55') from dual So this is OK to replace one value, but what about 20+, should I use 20+ REPLACE function or is there a more practical solution. All ideas are welcome.

    Read the article

  • Using LINQ to SQL and chained Replace

    - by White Dragon
    I have a need to replace multiple strings with others in a query from p in dx.Table where p.Field.Replace("A", "a").Replace("B", "b").ToLower() = SomeVar select p Which provides a nice single SQL statement with the relevant REPLACE() sql commands. All good :) I need to do this in a few queries around the application... So i'm looking for some help in this regard; that will work as above as a single SQL hit/command on the server It seems from looking around i can't use RegEx as there is no SQL eq Being a LINQ newbie is there a nice way for me to do this? eg is it possible to get it as a IQueryable "var result" say and pass that to a function to add needed .Replace()'s and pass back? Can i get a quick example of how if so? EDIT: This seems to work! does it look like it would be a problem? var data = from p in dx.Videos select p; data = AddReplacements(data, checkMediaItem); theitem = data.FirstOrDefault(); ... public IQueryable<Video> AddReplacements(IQueryable<Video> DataSet, string checkMediaItem) { return DataSet.Where(p => p.Title.Replace(" ", "-").Replace("&", "-").Replace("?", "-") == checkMediaItem); }

    Read the article

  • Find/Replace Paragraph End (^13) in Microsoft Word 2007 Merges Paragraphs

    - by Mike Blyth
    I need to replace a target at the beginning of lines with something else. Without wildcards, I can say to replace "^pTarget" with "^pReplacement". With wildcards enabled, I use replace "^13Target" with "^13Replacement". The replacement is successful except that the paragraph is now merged with the previous one in a strange way: The end-paragraph mark is still in place and the paragraph begins on a new line, but Triple clicking to select paragraph selects both the changed paragraph and the one above In a macro, starting in the paragraph above and extending the selection to the end of paragraph causes both paragraphs to be selected. Inter-paragraph spacing disappears between the changed paragraph and the one above. In essence, the paragraph boundary has been removed although the end-paragraph mark is still shown. To duplicate this problem, make a new document Line 1 Line 2 Line 3 (separate paragraphs). Find and replace (with wildcards on) "^13" with "^13". If your result is the same as mine, you will see the problems listed above. I can work around this in the usual way of replacing ^p with something else first, e.g. "^p" = "$", then "$target" = "$replacement", but I'm curious about what's going on. (This is using Word 2007 on Windows 7) I don't know Word XML, but the XML output seems to correspond with the above. Replacing ^13 with ^13 moves the paragraphs together in almost the same way as replacing end-paragraph with end-line (^p = ^l). Here is the relevant XML of the original "Line 1, Line 2, Line 3" in separate paragraphs: <w:p w:rsidR="00BB3032" w:rsidRDefault="00027252"> <w:r><w:t>Line 1</w:t></w:r> </w:p> <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 2</w:t></w:r> </w:p> <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 3</w:t></w:r> </w:p> Now after replacing ^13 with ^13: <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 1</w:t></w:r> <w:r w:rsidR="00C57863"><w:cr/></w:r> <w:r><w:t>Line 2</w:t></w:r> <w:r w:rsidR="00C57863"><w:cr/></w:r> <w:r><w:t>Line 3</w:t></w:r> <w:r w:rsidR="00C57863"><w:cr/></w:r> </w:p> Now original after replacement of ^p with ^l (convert end-paragraph to end-line) <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 1</w:t></w:r> <w:r w:rsidR="00AC7B51"><w:br/></w:r> <w:r><w:t>Line 2</w:t></w:r> <w:r w:rsidR="00AC7B51"><w:br/></w:r> <w:r><w:t>Line 3</w:t></w:r> <w:r w:rsidR="00AC7B51"><w:br/></w:r> </w:p>

    Read the article

  • Java replace slow?

    - by cpf
    Hi StackOverflow, I have a Java application that makes heavy use of a large file, to read, process and give through to SolrEmbeddedServer (http://lucene.apache.org/solr/). One of the functions does basic HTML escaping: private String htmlEscape(String input) { return input.replace("&", "&amp;").replace(">", "&gt;").replace("<", "&lt;") .replace("'", "&apos;").replaceAll("\"", "&quot;"); } While profiling the application, the program spends roughly 58% of the time in this function, a total of 47% in replace, and 11% in replaceAll. Now, is the Java replace that slow, or am I on the right path and should I consider the program efficient enough to have its bottleneck in Java and not in my code? (Or am I replacing wrong?) Thanks in advance!

    Read the article

  • Is str.replace(..).replace(..) ad nauseam a standard idiom in Python?

    - by meeselet
    For instance, say I wanted a function to escape a string for use in HTML (as in Django's escape filter): def escape(string): """ Returns the given string with ampersands, quotes and angle brackets encoded. """ return string.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace("'", '&#39;').replace('"', '&quot;') This works, but it gets ugly quickly and appears to have poor algorithmic performance (in this example, the string is repeatedly traversed 5 times). What would be better is something like this: def escape(string): """ Returns the given string with ampersands, quotes and angle brackets encoded. """ # Note that ampersands must be escaped first; the rest can be escaped in # any order. return replace_multi(string.replace('&', '&amp;'), {'<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;'}) Does such a function exist, or is the standard Python idiom to use what I wrote before?

    Read the article

  • Find & Replace in blogger

    - by Benjol
    (I just learnt that Yahoo are shutting down Geocities, this is a bummer as I used my account there to host two icons, in the days when Blogger didn't upload gifs. Now those two icons are referenced in every one of my 600+ posts). Blogger doesn't have a "Find & Replace in all posts" function. I'm wondering about using the API to hack something together, and wondered if anyone has already tried playing with the API, if there are any tips or things to avoid. Also if there isn't a sneaky shortcut (like switching to ftp, doing the replace locally then switching back?). Not 100% programming related, please be lenient, or at least answer my question before closing it!

    Read the article

  • Complex (?) Unix Text Replace Command

    - by Matrym
    What's the command line equivalent of: For every file that contains "AAA" within its contents, find "BBB" and replace it with "CCC" Thus, the command would match and replace BBB in a file: <html> <head></head> <body> AAA Hello world! BBB </body> </html> But Not in a file: <html> <head></head> <body> Don't match me! BBB </body> </html> Thanks in advance!

    Read the article

  • replace a random word of a string with a random replacement

    - by tpickett
    I am developing a script that takes an article, searches the article for a "keyword" and then randomly replaces that keyword with an anchor link. I have the script working as it should, however I need to be able to have an array of "replacements" for the function to loop through and insert at the random location. So the first random position would get anchor link #1. The second random position would get anchor link #2. The third random position would get anchor link #3. etc... I found half of the answer to my question here: PHP replace a random word of a string public function replace_random ($str, $search, $replace, $n) { // Get all occurences of $search and their offsets within the string $count = preg_match_all('/\b'.preg_quote($search, '/').'\b/', $str, $matches, PREG_OFFSET_CAPTURE); // Get string length information so we can account for replacement strings that are of a different length to the search string $searchLen = strlen($search); $diff = strlen($replace) - $searchLen; $offset = 0; // Loop $n random matches and replace them, if $n < 1 || $n > $count, replace all matches $toReplace = ($n < 1 || $n > $count) ? array_keys($matches[0]) : (array) array_rand($matches[0], $n); foreach ($toReplace as $match) { $str = substr($str, 0, $matches[0][$match][1] + $offset).$replace.substr($str, $matches[0][$match][1] + $searchLen + $offset); $offset += $diff; } return $str; } So my question is, How can i alter this function to accept an array for the $replace variable?

    Read the article

  • Word Automation : Replace do not work after TypeText

    - by wishper
    I need to generate doc (real doc, not docx) files, the "best" way i have found is to use word automation (Word 2010). I have files that I open, and then replace values inside before saving it on a new name. (Ex : I replace "" with "155023"). To do this, I use the Application.Selection.Find. I just had a problem when the new value had more than 255 characters (Thanks Microsofts limitations ...). To avoid this problem, i use TypeText in this case. My problem now is once I use TypeText, the Replace do not work anymore .. And I can't find why. Any idea will be greatly appreciated. My code is in a function, called in a foreach with each values to replace : private void Replace(Application app, string name, string newValue) { Selection selection = app.Selection; Find find = selection.Find; Replacement replacement = find.Replacement; find.ClearFormatting(); find.Text = "<" + name + ">"; // Word limitation : can't replace with more than 255 characters, // use another way to do it if that's the case if (tempNewValue.Length < 255) { replacement.ClearFormatting(); replacement.Text = tempNewValue; find.Execute(Replace: replaceAll); } else { while (find.Execute()) { selection.TypeText(tempNewValue); } } Marshal.ReleaseComObject(replacement); Marshal.ReleaseComObject(find); Marshal.ReleaseComObject(selection); }

    Read the article

  • Javascript Replace text in string

    - by Tegan Snyder
    I'm having some troubles getting regex to replace all occurances of a string within a string. **What to replace:** href="/newsroom **Replace with this:** href="http://intranet/newsroom This isn't working: str.replace(/href="/newsroom/g, 'href="http://intranet/newsroom"'); Any ideas? Thanks, Tegan

    Read the article

  • replace a 'space' char in filename with an underscore

    - by user38730
    I have a bunch of files in a directory with 'spaces' in the filename. How do I perform a bulk rename of all filenames with 'spaces' and replace them with an '_' char. Looking at the other solutions, I've tried the following command w/o success: find . -name '* *' -exec rename ' ' '_' {} + find: rename: No such file or directory

    Read the article

  • grep + sed for find & replace fun!

    - by Jim Greenleaf
    I have a dev copy of a website set up that has quite a few hardcoded references to its live counterpart. I would like to replace all occurrences of "www." with "dev." in all files. I think I can use a combination of grep + sed, but I'm not sure how.

    Read the article

  • shell script or command to search and replace [closed]

    - by Redbox
    Possible Duplicate: My server’s been hacked EMERGENCY lately website on my server has been infected with nasty javascript like this: http://pastebin.com/7XCidF6C i wonder is there any where to search and remove the entire script block? i only know how to search which files: find /home/loudcom/public_html/tv -iname '.' | xargs grep --color 'f1930e\|fff309' how do i apply sed or any other command to replace the entire block of nasty code to empty? im using Centos 6.

    Read the article

  • Outlook VBA - Find & Replace Incoming Emails

    - by user1912198
    Good morning everyone at Stackoverflow, I am trying to find a VBA script that finds and replaces a certain text in incoming e-mails. So far i've been unable to find such a script that is working. I found several scripts to find and replace stuff in the e-mail but these don't work as a rule on incoming e-mails, they only work on outgoing / creating e-mails. Does anyone have such a script that they can share with me? I would like to find & replace a certain text on every incoming e-mail. I would really apreciate it! Regards, Kris ps: I don't know how to program a whole VBA script, that's why I am asking here :) Current Code: Sub testing(MyMail As MailItem) Dim mail As MailItem Dim Inbox As Outlook.Folder Set Inbox = Session.GetDefaultFolder(olFolderInbox) For Each mail In Inbox.Items 'change subject mail.Subject = "TESTING" 'replace body text If mail.BodyFormat = olFormatHTML Then mail.HTMLBody = Replace(mail.HTMLBody, "Test 123", "TESTING") Else mail.Body = Replace(mail.Body, "Test 123", "TESTING") End If Next mail End Sub

    Read the article

  • Read/Write/Find/Replace huge csv file

    - by notapipe
    I have a huge (4,5 GB) csv file.. I need to perform basic cut and paste, replace operations for some columns.. the data is pretty well organized.. the only problem is I cannot play with it with Excel because of the size (2000 rows, 550000 columns). here is some part of the data: ID,Affection,Sex,DRB1_1,DRB1_2,SENum,SEStatus,AntiCCP,RFUW,rs3094315,rs12562034,rs3934834,rs9442372,rs3737728 D0024949,0,F,0101,0401,SS,yes,?,?,A_A,A_A,G_G,G_G D0024302,0,F,0101,7,SN,yes,?,?,A_A,G_G,A_G,?_? D0023151,0,F,0101,11,SN,yes,?,?,A_A,G_G,G_G,G_G I need to remove 4th, 5th, 6th, 7th, 8th and 9th columns; I need to find every _ character from column 10 onwards and replace it with a space ( ) character; I need to replace every ? with zero (0); I need to replace every comma with a tab; I need to remove first row (that has column names; I need to replace every 0 with 1, every 1 with 2 and every ? with 0 in 2nd column; I need to replace F with 2, M with 1 and ? with 0 in 3rd column; so that in the resulting file the output reads: D0024949 1 2 A A A A G G G G D0024302 1 2 A A G G A G 0 0 D0023151 1 2 A A G G G G G G (both input and output should read one line per row, ne extra blank row) Is there a memory efficient way of doing that with java(and I need a code to do that) or a usable tool for playing with this large data so that I can easily apply Excel functionality..

    Read the article

  • Using search and replace to remove line breaks in Open Office

    - by chrisfs
    Hi, I've imported a document into Open Office and it has a number of hard returns in wrong places. In MS Word, I could use the search and replace to simply get rid of them all easily, but Open Office's earch won't find them. I tried /n with the 'use regular expressions' box checked, but it seems that only looks for 'shift-enter' breaks and not ordinary hard returns. Is there another way to remove them all quickly, or do I have to go manually through the document and remove each one individually. This is a surprising oversight for Open Office.

    Read the article

  • How to scrub a document of all text between brackets with find and replace

    - by sam
    I have a log file and I need to find all instances of <password> hash here </password> and remove the hash and replace it with some dummy text like aaa-aaa-aaa-aaaa. The recurring search argument is anything that matches a bracket that starts with <password> and ends with </password>. All the hashes being replaced will be different. What's the easiest way to go a bout this? The log is on a windows machine. Probably easiest would be to use MS word for me, unless it's achievable with wordpad, notepad, or some other light weight editor like textpad. thanks

    Read the article

  • Powerful search-replace GUI app for Mac?

    - by fig-gnuton
    What's the best dedicated search-and-replace GUI tool on a Mac? "Find & Replace It!" seems decent, but they've ridiculously disabled the replace function in the demo, so I can't give it a real test before paying. Is there anything else comparable or better?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >