Search Results

Search found 7529 results on 302 pages for 'replace'.

Page 44/302 | < Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >

  • Java regex replace multiple file paths in a large String

    - by Joe Goble
    So a Regex pro I am not, and I'm looking for a good way to do this. I have a large string which contains a variable number <img> tags. I need to change the path on all of these images to images/. The large string also contains other stuff not just these img's. <img src='http://server.com/stuff1/img1.jpg' /> <img src='http://server.com/stuff2/img2.png' /> Replacing the server name with a ReplaceAll() I could do, it's the variable path in the middle I'm clueless on how to include. It doesn't necessarily need to be a regex, but looping through the entire string just seems wasteful.

    Read the article

  • Find and replace table/field names in Access?

    - by richardtallent
    I've been handed a rather large, old, and crusty Access 2000/2003 database to clean up. I'll need to rename a number of tables and fields, but need to do so in a way that doesn't break existing queries. (Fortunately, there are no macros, forms, or reports to worry about.) I've heard there are some commercial tools to make this job easier, but only found one (http://www.rickworld.com/products.html). Can anyone recommend this software, or any alternatives?

    Read the article

  • Replace relative urls to absolute

    - by Rocky Singh
    I have the html source of a page in a form of string with me: <html> <head> <link rel="stylesheet" type="text/css" href="/css/all.css" /> </head> <body> <a href="/test.aspx">Test</a> <a href="http://mysite.com">Test</a> <img src="/images/test.jpg"/> <img src="http://mysite.com/images/test.jpg"/> </body> </html> I want to convert all the relative paths to absolute. I want the output be: <html> <head> <link rel="stylesheet" type="text/css" href="http://mysite.com/css/all.css" /> </head> <body> <a href="http://mysite.com/test.aspx">Test</a> <a href="http://mysite.com">Test</a> <img src="http://mysite.com/images/test.jpg"/> <img src="http://mysite.com/images/test.jpg"/> </body> </html> Note: I want only the relative paths to be converted to absolute ones in that string. The absolute ones which are already in that string should not be touched, they are fine to me as they are already absolute. Can this be done by regex or other means?

    Read the article

  • Replace conditional with polymorphism refactoring or similar?

    - by Anders Svensson
    Hi, I have tried to ask a variant of this question before. I got some helpful answers, but still nothing that felt quite right to me. It seems to me this shouldn't really be that hard a nut to crack, but I'm not able to find an elegant simple solution. (Here's my previous post, but please try to look at the problem stated here as procedural code first so as not to be influenced by the earlier explanation which seemed to lead to very complicated solutions: http://stackoverflow.com/questions/2772858/design-pattern-for-cost-calculator-app ) Basically, the problem is to create a calculator for hours needed for projects that can contain a number of services. In this case "writing" and "analysis". The hours are calculated differently for the different services: writing is calculated by multiplying a "per product" hour rate with the number of products, and the more products are included in the project, the lower the hour rate is, but the total number of hours is accumulated progressively (i.e. for a medium-sized project you take both the small range pricing and then add the medium range pricing up to the number of actual products). Whereas for analysis it's much simpler, it is just a bulk rate for each size range. How would you be able to refactor this into an elegant and preferably simple object-oriented version (please note that I would never write it like this in a purely procedural manner, this is just to show the problem in another way succinctly). I have been thinking in terms of factory, strategy and decorator patterns, but can't get any to work well. (I read Head First Design Patterns a while back, and both the decorator and factory patterns described have some similarities to this problem, but I have trouble seeing them as good solutions as stated there. The decorator example seems very complicated for just adding condiments, but maybe it could work better here, I don't know. And the factory pattern example with the pizza factory...well it just seems to create such a ridiculous explosion of classes, at least in their example. I have found good use for factory patterns before, but I can't see how I could use it here without getting a really complicated set of classes) The main goal would be to only have to change in one place (loose coupling etc) if I were to add a new parameter (say another size, like XSMALL, and/or another service, like "Administration"). Here's the procedural code example: public class Conditional { private int _numberOfManuals; private string _serviceType; private const int SMALL = 2; private const int MEDIUM = 8; public int GetHours() { if (_numberOfManuals <= SMALL) { if (_serviceType == "writing") return 30 * _numberOfManuals; if (_serviceType == "analysis") return 10; } else if (_numberOfManuals <= MEDIUM) { if (_serviceType == "writing") return (SMALL * 30) + (20 * _numberOfManuals - SMALL); if (_serviceType == "analysis") return 20; } else //i.e. LARGE { if (_serviceType == "writing") return (SMALL * 30) + (20 * (MEDIUM - SMALL)) + (10 * _numberOfManuals - MEDIUM); if (_serviceType == "analysis") return 30; } return 0; //Just a default fallback for this contrived example } } All replies are appreciated! I hope someone has a really elegant solution to this problem that I actually thought from the beginning would be really simple... Regards, Anders

    Read the article

  • Regex, replace path to resource, modify resource name

    - by jerome
    Hi all, I'd like to use a JS regex to take a string such as the following: 'http://www.somedomain.com/some_directory/some_other_directory/some_image.jpg' And turn it into this: 'http://www.some_other_domain.com/another_directory/yet_another_directory/size1_some_image.jpg' Any hints? Additionally, any pointers for books or other resources that give a gentle introduction to mastering regexes in JS and other languages?

    Read the article

  • arbitrary vire connection / search and replace

    - by fatai
    input :["vire_connection",[1, 2, [ 3, [ 4, "connect"]]], ["connect", [3 , 5] ] ] output:["vire_connection",[ 1, 2, [ 3, [ 4, [ 3, 5 ] ] ] ] ], [ [ 3 , 5] ] ] after connection ( simply copying [3,5] to other wanted position ) , remove connect word input :["vire_connection", [ [ [ ["connect", [ 3, 4 ] ] ] ] ], [ 2, "connect"]] output :["vire_connection",[[[[[3,4]]]]], [ 2, [ 3 , 4 ]]] after connection ( simply copying [3,4] to other wanted position ) , remove connect word how can I do ?

    Read the article

  • question of sed replace

    - by chun
    hi i have a config file xml <tflow name="CENTRE" inputDTD="/JOBS/cnav/etc/jobReporting/batch/dtd/dtd-ContactCentre.dtd" inputFile="/JOBS/cnav/etc/jobReporting/import/2010.05.02.CONTACTCENTRE.xml" logPath="/JOBS/cnav/etc/jobReporting/logs/" rejectPath="/JOBS/cnav/etc/jobReporting/rejets/"/> <tflow name="SKILL" inputDTD="/JOBS/cnav/etc/jobReporting/batch/dtd/dtd-Skill.dtd" inputFile="/JOBS/cnav/etc/jobReporting/import/2010.05.02.SKILLS.xml" logPath="/JOBS/cnav/etc/jobReporting/logs/" rejectPath="/JOBS/cnav/etc/jobReporting/rejets/"/> my shell is aim to change, by example '2010.05.02.SKILLS.xml' with 'newdate.SKILLS.xml' currently i think of SED, i wrote: sed 's/(import\/)(\d{4}.\d{2}.\d{2})/$1$newdate/g' myfile.xml it doesn't work,i test the pattern with RegExr(a site) which is fine. is it a problem of synthesis of SED? thanks.

    Read the article

  • how to replace ie error

    - by Jeny
    Hi friends, document.getElementId(id).style.display ='table-cell'. this gives error message in ie, this is ie bug or any other solutions please give any other solutions

    Read the article

  • php regex - replace on "\${1}"

    - by Qiao
    found this regex: insert " " every 10 characters: $text = preg_replace("|(.{10})|u", "\${1}"." ", $text); can you, please, explain what \${1} means. Why using \ and what curly brackets means?

    Read the article

  • Replace Components.classesByID with document.implementation.createDocument

    - by Earl Smith
    I am not the author of this code, but it is no longer maintained. So I am trying to fix it, but I have very little experience in javascript. Since Firefox 9, Components.classesByID["{3a9cd622-264d-11d4-ba06-0060b0fc76dd}"]. has been obsolete. Instead, it is suggested that document.implementation.createDocument be used. Can someone here show me how to implement these changes? I seem to be, just banging my head with everything I have tried. The example given at Mozilla developer network is: var doc = document.implementation.createDocument ("http://www.w3.org/1999/xhtml", "html", null); var body = document.createElementNS("http://www.w3.org/1999/xhtml", "body"); body.setAttribute("id", "abc"); doc.documentElement.appendChild(body); alert(doc.getElementById("abc")); // [object HTMLBodyElement] and the code in the .jsm I am trying to fix is: this.fgImageData = {}; this.fgImageData["check"] = [ " *", " **", "* ***", "** *** ", "***** ", " *** ", " * "]; this.fgImageData["radio"] = [ " **** ", "******", "******", "******", "******", " **** "]; this.fgImageData["menu-ltr"] = [ "* ", "** ", "*** ", "****", "*** ", "** ", "* "]; this.fgImageData["menu-rtl"] = [ " *", " **", " ***", "****", " ***", " **", " *"]; // I think I'm doing something slightly wrong when creating the document // but I'm not sure. It works though. *FIX* var domi = Components.classesByID["{3a9cd622-264d-11d4-ba06-0060b0fc76dd}"]. createInstance(Components.interfaces.nsIDOMDOMImplementation); this.document = domi.createDocument("http://www.w3.org/1999/xhtml", "html", null); this.canvas = this.document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas"); for(var name in this.fgImageData) { if (this.fgImageData.hasOwnProperty(name)) { var data = this.fgImageData[name]; var width = data[0].length; var height = data.length; this.canvas.width = width; this.canvas.height = height; var g = this.canvas.getContext("2d"); g.clearRect(0, 0, width, height); var idata = g.getImageData(0, 0, width, height); for(var y=0, oy=0; y<height; y++, oy+=idata.width*4) for(var x=0, ox=oy; x<width; x++, ox+=4) idata.data[ox+3] = data[y][x] == " " ? 0 : 255; this.fgImageData[name] = idata; } } },

    Read the article

  • jQuery replace first string match

    - by P4tient
    I have an array, like var acronyms = { 'NAS': 'Nunc ac sagittis', 'MTCP': 'Morbi tempor congue porta' }; I need to find first match of each acronym and wrap around with tag via jQuery. E.g. <div id="wrap">NAS dui pellentesque pretium augue. MTCP pellentesque pretium augue. NAS ac ornare lectus MTCP nec.</div> becomes <div id="wrap"><acronym title="Nunc ac sagittis">NAS</acronym> dui pellentesque pretium augue. <acronym title="Morbi tempor congue porta">MTCP</acronym> pellentesque pretium augue. NAS ac ornare lectus MTCP nec.</div> Thanks.

    Read the article

  • How do I replace NOT EXISTS with JOIN?

    - by YelizavetaYR
    I've got the following query: select distinct a.id, a.name from Employee a join Dependencies b on a.id = b.eid where not exists ( select * from Dependencies d where b.id = d.id and d.name = 'Apple' ) and exists ( select * from Dependencies c where b.id = c.id and c.name = 'Orange' ); I have two tables, relatively simple. The first Employee has an id column and a name column The second table Dependencies has 3 column, an id, an eid (employee id to link) and names (apple, orange etc). the data looks like this Employee table looks like this id | name ----------- 1 | Pat 2 | Tom 3 | Rob 4 | Sam Dependencies id | eid | Name -------------------- 1 | 1 | Orange 2 | 1 | Apple 3 | 2 | Strawberry 4 | 2 | Apple 5 | 3 | Orange 6 | 3 | Banana As you can see Pat has both Orange and Apple and he needs to be excluded and it has to be via joins and i can't seem to get it to work. Ultimately the data should only return Rob

    Read the article

  • F# replace ref variable with something fun

    - by Stephen Swensen
    I have the following F# functions which makes use of a ref variable to seed and keep track of a running total, something tells me this isn't in the spirit of fp or even particular clear on its own. I'd like some direction on the clearest (possible fp, but if an imperative approach is clearer I'd be open to that) way to express this in F#. Note that selectItem implements a random weighted selection algorithm. type WeightedItem(id: int, weight: int) = member self.id = id member self.weight = weight let selectItem (items: WeightedItem list) (rand:System.Random) = let totalWeight = List.sumBy (fun (item: WeightedItem) -> item.weight) items let selection = rand.Next(totalWeight) + 1 let runningWeight = ref 0 List.find (fun (item: WeightedItem) -> runningWeight := !runningWeight + item.weight !runningWeight >= selection) items let items = [new WeightedItem(1,100); new WeightedItem(2,50); new WeightedItem(3,25)] let selection = selectItem items (new System.Random())

    Read the article

  • How Best to Replace PL/SQL with C#?

    - by Mike
    Hi, I write a lot of one-off Oracle SQL queries/reports (in Toad), and sometimes they can get complex, involving lots of unions, joins, and subqueries, and/or requiring dynamic SQL, and/or procedural logic. PL/SQL is custom made for handling these situations, but as a language it does not compare to C#, and even if it did, it's tooling does not, and if even that did, forcing yet another language on the team is something to be avoided whenever possible. Experience has shown me that using SQL for the set based processing, coupled with C# for the procedural processing, is a powerful combination indeed, and far more readable, maintainable and enhanceable than PL/SQL. So, we end up with a number of small C# programs which typically would construct a SQL query string piece by piece and/or run several queries and process them as needed. This kind of code could easily be a disaster, but a good developer can make this work out quite well, and end up with very readable code. So, I don't think it's a bad way to code for smaller DB focused projects. My main question is, how best to create and package all these little C# programs that run ad hoc queries and reports against the database? Right now I create little report objects in a DLL, developed and tested with NUnit, but then I continue to use NUnit as the GUI to select and run them. NUnit just happens to provide a nice GUI for this kind of thing, even after testing has been completed. I'm also interested in suggestions for reporting apps generally. I feel like there is a missing piece or product. The perfect tool would allow writing and running C# inside of Toad, or SQL inside of Visual Studio, along with simple reporting facilities. All ideas will be appreciated, but let's make the assumption that PL/SQL is not the solution.

    Read the article

  • Import a number of csv files and replace NA by Zeros

    - by tao.hong
    I know how to do this individually. However, I have more than 1000 files. I decided to use a for loop. However, it seems like I did not find the correct way to evaluate my variables. Here is my code setwd('C:/data') filenames=dir() #find file names for (i in filenames){ adt = substr(x = i, start = 1, stop = nchar(i)-4) name=paste("data_", adt, sep="") assign(name, read.csv(i,header=T,sep=",")) #read each file and assign a variable name starting with data_ to it func=paste('name[is.na(name)] <- 0',sep="") # here is the place I have problem. R will not consider name is a parameter whose values change in each iteration eval((text=func)) }

    Read the article

  • Proper Regex to find and replace escaped UTF-8 strings

    - by Piet Binnenbocht
    (edited) I am reading a JSON file that includes some UTF-8 characters that are encoded like this: "\uf36b". I am trying to write a RegExp to convert this to an HTML entity that looks like "&#x1F36B;". This displays the character correctly in my html page. I haven't been able to correctly display the character that should be associated with "\uf36b", especially when in a longer sentence that also includes other text. How can I write a regexp that replaces strings like "\uf4d6" and "\uf36b" but leaves other text alone? Example: var str = "I need \uf36b #chocolate"; This should be converted to: I need &#x1F36B; #chocolate;

    Read the article

  • Replace URL with a link using regex in python

    - by user122750
    how do I convert some text to a link? Back in PHP, I used this piece of code that worked well for my purpose: $text = preg_replace("#(^|[\n ])(([\w]+?://[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\3</a>", $text); $text = preg_replace("#(^|[\n ])(((www|ftp)\.[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\3</a>", $text); I tried around in Python, but was unable to get it to work.. Would be very nice if someone could translate this to Python :)..

    Read the article

  • Regular Expression - Capture and Replace Select Sequences

    - by Chad
    Take the following file... ABCD,1234,http://example.com/mpe.exthttp://example/xyz.ext EFGH,5678,http://example.com/wer.exthttp://example/ljn.ext Note that "ext" is a constant file extension throughout the file. I am looking for an expression to turn that file into something like this... ABCD,1234,http://example.com/mpe.ext ABCD,1234,http://example/xyz.ext EFGH,5678,http://example.com/wer.ext EFGH,5678,http://example/ljn.ext In a nutshell I need to capture everything up to the urls. Then I need to capture each URL and put them on their own line with the leading capture. I am working with sed to do this and I cannot figure out how to make it work correctly. Any ideas?

    Read the article

  • Replace ",**" with a linebreak using RegEx (or something else)

    - by John
    I'm getting started with RegEx and I was wondering if anyone could help me craft a statement to convert coordinates as follows: 145.00694,-37.80421,9 145.00686,-37.80382,9 145.00595,-37.8035,16 145.00586,-37.80301,16 to 145.00694,-37.80421 145.00686,-37.80382 145.00595,-37.8035 145.00586,-37.80301 (Strip off the last comma and value and turn it into a line break.) I can't figure out how to use wildcards to do something like that. Any help would be greatly appreciated! Thanks.

    Read the article

< Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >