Search Results

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

Page 22/302 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Find multiple line spanning text and replace using Powershell

    - by MrGrant
    Hello, I am using a regular expression search to match up and replace some text. The text can span multiple lines (may or may not have line breaks). Currently I have this: $regex = "\<\?php eval.*?\>" Get-ChildItem -exclude *.bak | Where-Object {$_.Attributes -ne "Directory"} |ForEach-Object { $text = [string]::Join("`n", (Get-Content $_)) $text -replace $RegEx ,"REPLACED"}

    Read the article

  • Replace character between strings

    - by trembon
    Maybe it's just too late for me to do this, but I'm trying to replace a character between 2 string with regex in PHP. Example string: other | text [tag]text|more text|and more[/tag] end | text My goal is to replace | with <br/> between [tag] and [/tag]. Tried with this, seems it wasn't that easy though: /<td>(\|)<td>/gsi Searched a bit, but couldn't make out an answer with the stuff I found. Hope you can help, thanks

    Read the article

  • replace new lines with comas in shell

    - by mpapis
    I want to replace new lines in text with coma or space but do not change the last new line. I know of this question: How to replace new lines with tab characters - but it does produce an tab on end instead of new line. So far I have come with: awk 'NR>1{printf","} {printf $1} END{printf"\n"}' Is there an easier way to do this? This is not an assignment, I am just curious want to level up my scripting.

    Read the article

  • Replace all URL unless it is allowed

    - by ratamaster
    I had a regex that replaced all URLs from a given string: my_string = "www.example.com test www.mysite.com" my_string.gsub!(/[a-zA-Z0-9\-\.]+\.(com|net|de|org|uk|biz|info|co.uk|es|de)(\/\S*)?/i,'(site hidden)') As a result of the above I get: "(site hidden) test (site hidden)" How could I change the regex to not replace www.mysite.com ??? It means that the replace should output "(site hidden) test www.mysite.com" Thanks !

    Read the article

  • Hide/Replace Nginx Location Header?

    - by Steven Ou
    I am trying to pass a PCI compliance test, and I'm getting a single "high risk vulnerability". The problem is described as: Information on the machine which a web server is located is sometimes included in the header of a web page. Under certain circumstances that information may include local information from behind a firewall or proxy server such as the local IP address. It looks like Nginx is responding with: Service: https Received: HTTP/1.1 302 Found Cache-Control: no-cache Content-Type: text/html; charset=utf-8 Location: http://ip-10-194-73-254/ Server: nginx/1.0.4 + Phusion Passenger 3.0.7 (mod_rails/mod_rack) Status: 302 X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7 X-Runtime: 0 Content-Length: 90 Connection: Close <html><body>You are being <a href="http://ip-10-194-73-254/">redirect ed</a>.</body></html> I'm no expert, so please correct me if I'm wrong: but from what I gathered, I think the problem is that the Location header is returning http://ip-10-194-73-254/, which is a private address, when it should be returning our domain name (which is ravn.com). So, I'm guessing I need to either hide or replace the Location header somehow? I'm a programmer and not a server admin so I have no idea what to do... Any help would be greatly appreciated! Also, might I add that we're running more than 1 server, so the configuration would need to be transferable to any server with any private address.

    Read the article

  • Upgrade or replace?

    - by Felix
    My current PC is about four years old, although I have made upgrades to it throughout its existence. The current specs are: (old) Intel Pentium D 2.80Ghz (32K L1 / 2M L2), Gigabyte 945GCMX-S2 motherboard (old) 2.5GB DDR2 (slot0: 512MB @ 533Mhz; slot1: 2GB @ 667Mhz) (new) HIS Radeon HD 4670 - I think this is limited by the motherboard not supporting PCIe 2.0 (?) (old) WD Caviar 160GB - pretty slow (new) WD Caviar Black 640GB (if any more specs are relevant, let me know and I'll add them) Now, on to my question. I've been having performance issues lately, both in video games and in intensive applications. A couple of examples: Android application development (running Eclipse and the Android emulator) is painfully slow (on Linux). I only realized this when, at my new job as an Android dev, both tools are MUCH quicker. (I'm not sure what CPU I have there) The guys at my new job got me NFS Hot Pursuit, in which I barely get like 5-10FPS, even with graphics options turned all the way down My guess is that the bottleneck in my system is my CPU, so I'm thinking of upgrading to a Quad Core i5 + new motherboard + 4GB DDR3 (or more, 'cause I know you'll all jump and say 8GB minimum). Now: Is that a good idea? Is my CPU really a bottleneck, or is the whole system too old and I should replace it? I run Windows 7 on the old, 160GB HDD (which is on IDE, by the way). Could this slow down games as well? Should I get a new drive for Windows if I want to play new games? I know nothing about power supplies. Could that be a problem / will it be a problem if I upgrade to an i5? How come DiRT2 works on full graphics settings (pretty amazing graphics by the way) and NFS Hot Pursuit pulls only 5-10FPS?

    Read the article

  • Can I write this regex in one step?

    - by Marin Doric
    This is the input string "23x +y-34 x + y+21x - 3y2-3x-y+2". I want to surround every '+' and '-' character with whitespaces but only if they are not allready sourrounded from left or right side. So my input string would look like this "23x + y - 34 x + y + 21x - 3y2 - 3x - y + 2". I wrote this code that does the job: Regex reg1 = new Regex(@"\+(?! )|\-(?! )"); input = reg1.Replace(input, delegate(Match m) { return m.Value + " "; }); Regex reg2 = new Regex(@"(?<! )\+|(?<! )\-"); input = reg2.Replace(input, delegate(Match m) { return " " + m.Value; }); explanation: reg1 // Match '+' followed by any character not ' ' (whitespace) or same thing for '-' reg2 // Same thing only that I match '+' or '-' not preceding by ' '(whitespace) delegate 1 and 2 just insert " " before and after m.Value ( match value ) Question is, is there a way to create just one regex and just one delegate? i.e. do this job in one step? I am a new to regex and I want to learn efficient way.

    Read the article

  • Selectively replacing words outside of tags using regular expressions in PHP?

    - by Gary Willoughby
    I have a paragraph of text and i want to replace some words using PHP (preg_replace). Here's a sample piece of text: This lesson addresses rhyming [one]words and ways[/one] that students may learn to identify these words. Topics include learning that rhyming words sound alike and these sounds all come from the [two]ending of the words[/two]. This can be accomplished by having students repeat sets of rhyming words so that they can say them and hear them. The students will also participate in a variety of rhyming word activities. In order to demonstrate mastery the students will listen to [three]sets of words[/three] and tell the teacher if the words rhyme or not. If you notice there are many occurances of the word 'words'. I want to replace all the occurances that don't occur inside any of the tags with the word 'birds'. So it looks like this: This lesson addresses rhyming [one]words and ways[/one] that students may learn to identify these birds. Topics include learning that rhyming birds sound alike and these sounds all come from the [two]ending of the words[/two]. This can be accomplished by having students repeat sets of rhyming birds so that they can say them and hear them. The students will also participate in a variety of rhyming word activities. In order to demonstrate mastery the students will listen to [three]sets of words[/three] and tell the teacher if the birds rhyme or not. Would you use regular expressions to accomplish this? Can a regular expression accomplish this?

    Read the article

  • Multiple calls to preg_replace alters result

    - by Hurpe
    I have a bunch of files that were named in a somewhat standard format. The standard form is basically this: [integer]_word1_word2_word3_ ... _wordn where a word could really be anything, but all words are separated by an underscore. There is really only 3 things I want to do to the text: 1.) I want to modify the integer, which is always at the beginning, so that something like "200" would become $ 200.00. 2.) replace any "words" of the form "with", "With", "w/", or "W/" with "with". 3.) Replace all underscores with a space. I wrote three different preg_replace calls to do the trick. They are as follows: 1.) $filename = preg_replace("/(^[0-9]+)/","$ $1.00",$filename) 2.) $filename = preg_replace("/_([wW]|[wW]ith)_/"," with ",$filename) 3.) $filename = preg_replace("/_/"," ",$filename); Each replacement works as expected when run individually, but when all three are run, the 2nd replacement is ignored. Why would something like that occur? Thanks for the help!

    Read the article

  • PHP Preg_replace after a specific amount of characters with a conditional

    - by Marc Ripley
    I've been working on this for a bit, but my regex is weak. I need to check to see if a number is a whole number (single digit) and append a ".001" to it if so. The problem is, it's in the middle of a line with values separated by commas. MATERIALS,1,1,9999;1 4PL1 PB_Mel,,1,6,0.173,0.173,0.375,0,0.375,0,0,0,0,2,0,1,1 Needs to be MATERIALS,1,1,9999;1 4PL1 PB_Mel,,1.001,6,0.173,0.173,0.375,0,0.375,0,0,0,0,2,0,1,1 The line must start with "MATERIALS". There are more than one MATERIALS lines. The value will always be after 5 commas. I was trying something like this to even replace the number, but I don't think the approach is quite right: $stripped = preg_replace('/(MATERIALS)(,.*?){4}(,\d+?),/', '\2,', $stripped); I tried going through a preg_match_all for if process, to at least get the conditional working, but I still have to replace the lines. for($i=0;$i<sizeof($materialsLines[0]);$i++) { $section = explode(",",$materialsLines[0][$i]); if (strlen($section[5]) == 1) { $section[5] .= ".001"; } $materialsLines[0][$i] = implode(",",$section); }

    Read the article

  • str_replace() and strpos() for arrays?

    - by Josh
    I'm working with an array of data that I've changed the names of some array keys, but I want the data to stay the same basically... Basically I want to be able to keep the data that's in the array stored in the DB, but I want to update the array key names associated with it. Previously the array would have looked like this: $var_opts['services'] = array('foo-1', 'foo-2', 'foo-3', 'foo-4'); Now the array keys are no longer prefixed with "foo", but rather with "bar" instead. So how can I update the array variable to get rid of the "foos" and replace with "bars" instead? Like so: $var_opts['services'] = array('bar-1', 'bar-2', 'bar-3', 'bar-4'); I'm already using if(isset($var_opts['services']['foo-1'])) { unset($var_opts['services']['foo-1']); } to get rid of the foos... I just need to figure out how to replace each foo with a bar. I thought I would use str_replace on the whole array, but to my dismay it only works on strings (go figure, heh) and not arrays.

    Read the article

  • pre_replace multi-dimensional array problem

    - by Martin
    I want to replace word groups by links. I use a multi-dimensional array to define these (in the real world there will be thousands of them). Here's the code: $text = "<html><body><pre> Here is Foo in text. Now come Baz? and Bar-X. Replace nothing here: Foo (followed by brackets). </pre></body></html>"; $s = array( array("t" => "Foo", "u" => "http://www.foo.com", "c" => "foo"), array("t" => "Baz?", "u" => "http://www.baz.net", "c" => "test"), array("t" => "Bar-X", "u" => "http://www.baz.org", "c" => "test") ); foreach ($s as $i => $row) { $replaced = preg_replace('/(?=\Q'.$row["t"].'\E[^(]+$)\b\Q'.$row["t"].'\E\b/m', '<a href="'.$row["u"].'" class="'.$row["c"].'">'.$row["t"].'</a>', $text); } echo $replaced; ?> The problem is that only one array element is replaced and not all. It's something about $text in peg_replace(). Anyone got a hint for me? Thanks!

    Read the article

  • Easiest way to replace preinstalled Windows 8 with new hard drive with Windows 7

    - by Andrew
    There are all kinds of questions and answers relevant moving Windows 8 to a new hard drive. I'm not seeing anything quite applicable to my situation. I have a new, unopened, unbooted notebook with pre-installed Windows 8. I will be replacing the hard drive before ever booting, unless that is not possible for some reason. I want to "downgrade" to Windows 7 Pro, and I want a clean installation. To do so legitimately, I apparently either need to: Upgrade Windows 8 to Windows 8 Pro using Windows 8 Pro Pack, then downgrade; or Just install a newly-licensed copy of Windows 7 Pro. (Let me know if I've missed an option.) Installation media is likely not a problem, though if I need something vendor-specific that I cannot otherwise download, that could present an issue (Asus notebook, if that matters). If I could, I would just buy the Pro Pack upgrade, swap the hard drive (without ever booting), then install Windows 7 Pro directly on the new hard drive, using the Pro Pack key for activation. Will this work? Are there any activation issues? Edited to clarify, as some comments and answers indicate confusion: Here is, ideally, what I want to do: Before ever powering on the notebook, remove the current hard drive. Replace this hard drive with a new, blank hard drive. Install a clean copy of Windows 7 Pro on this new, blank hard drive. Unless I have no choice to accomplish the end result (a clean install of Win7 Pro on the newly-installed, previously-blank hard drive), I am not wanting to: Install Windows 7 "over" the current Windows 8 install (after upgrading to Win8 Pro). That would involve using the currenly-installed hard drive. I want to use a new, different hard drive. Copy the Win8 install to the new hard drive, then install Windows 7 "over" that installation. Install Windows 7 "over" the current Windows 8 install (after upgrading to Win8 Pro), then copy the installation to the new hard drive. If I have to use one of those three options, I will, but only if there is no other choice. Please note that this question is not about licensing: I will purchase the necessary license(s) to accomplish this procedure legally (apparently either Win8 Pro Pack or Win7 Pro -- the former currently appears less expensive).

    Read the article

  • Hyphen vs Dash : Replace Dash with Hyphen

    - by soldieraman
    Alright so we had a problem recently In reporting services some of the String Columns were appearing as gibberish Chinese characters. On further investigation we found it is the hyphen. Well that's what we though first. On further investigation we found it a dash (or en dash) . Basically the reason this has happened is people copy pasting values into this column from word which converts hyphens into dashes automatically. But if you look at the database they both look the same. Though on the application side you can see the difference. How do I replace the dash with a normal hyphen. If you copy the value in put it in SQL server. A hyphen is gray while a dash is black but they both look exactly the same (i.e not bigger or smaller). Problem is I can't write a REPLACE script then (they are the freakin same) REPLACE ('-' with '-') is there a way special characters like the dash can be identified in SQL server? SQL Server v 2005

    Read the article

  • 'Hot code replace' not working -- Eclipse doesn't change any code on JBoss

    - by Bernhard V
    Hello, fellow visitors! I'm currently experiencing a problem with 'hot code replace' not working on Eclipse Galileo and JBoss 4.2.3. Among other applications I'm running an exploded Java WAR on my local JBoss. The project from which it is build is managed by Maven. I build the project using the Maven goal war:exploded and then I copy that directory to JBoss with an ANT script. When I'm now running the application and set a breakpoint anywhere in the code, Eclipse properly halts at that line in the debug mode. But when I'm making a change to the source file and save it, Eclipse doesn't apply this change to the JBoss. For example, when I make a normal code line into a comment, the debugger still steps over this comment as if it was regular Java code. Or when I remove a line, the debugger seems to get out of sync with the file and starts stepping over parenthesis. But I'm not getting any 'hot code replace error'-messages either. It seems to me that Eclipse applies the changes to the source files, but doesn't apply it to the JBoss. Are there any special preferences that have to be turned on in order to make hot code replace work? Or are there any mistakes in how I build and deploy the application to the JBoss? I'd appreciate your help very much. Thank you. Bernhard V

    Read the article

  • Replace text in word textbox objects using VSTO and C#

    - by Roberto
    Hi, I have to find/replace text from a word document. It works fine for plain text spread through the document, however when the text is in a textbox, the standard find/replace approach doesn't reach it. I found a vba solution, however since I am working in C#, I would like to find a solution in C#. The word document is in 2007 format and my visual studio is 2010. I am using .Net Framework 3.5, but if required, I can consider moving to 4.0. Here is the code for the find/replace that only works with plain text (not in word textbox objects): object Missing = System.Reflection.Missing.Value; object fileToOpen = (object)@"c:\doc.docx"; object fileToSave = (object)@"c:\doc.docx"; Word.Application app = new Word.ApplicationClass(); Word.Document doc = new Word.Document(); try { doc = app.Documents.Open(ref fileToOpen, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing); object replaceAll = Word.WdReplace.wdReplaceAll; app.Selection.Find.ClearFormatting(); app.Selection.Find.Text = "MyTextForReplacement"; app.Selection.Find.Replacement.ClearFormatting(); app.Selection.Find.Replacement.Text = "Found you!"; app.Selection.Find.Execute( ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref replaceAll, ref Missing, ref Missing, ref Missing, ref Missing); I also tried using the below code, but didn't work as well: foreach(Word.Shape s in app.ActiveDocument.Shapes) { if(s.TextFrame.HasText >= 1) //The value is always 0 or -1, and even leaving 0 go forward, // it doesn't work, because there is no text in there... { foreach(Word.Field f in s.TextFrame.TextRange.Fields) { switch( f.Type) { . . //I never reached this point . } } } Any help will be appreciated... Thanks, -- Roberto Lopes

    Read the article

  • Replace image in word doc using OpenXML

    - by fearofawhackplanet
    Following on from my last question here OpenXML looks like it probably does exactly what I want, but the documentation is terrible. An hour of googling hasn't got me any closer to figuring out what I need to do. I have a word document. I want to add an image to that word document (using word) in such a way that I can then open the document in OpenXML and replace that image. Should be simple enough, yes? I'm assuming I should be able to give my image 'placeholder' an id of some sort and then use GetPartById to locate the image and replace it. Would this be the correct method? What is this Id? How do you add it using Word? Every example I can find which does anything remotely similar starts by building the whole word document from scratch in ML, which really isn't a lot of use. EDIT: it occured to me that it would be easier to just replace the image in the media folder with the new image, but again can't find any indication of how to do this.

    Read the article

  • Replace delimited block of text in file with the contents of another file

    - by rmarimon
    I need to write a simple script to replace a block of text in a configuration file with the contents of another file. Let's assume with have the following simplified files: server.xml <?xml version='1.0' encoding='UTF-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Service name="Catalina"> <Connector port="80" protocol="HTTP/1.1"/> <Engine name="Catalina" defaultHost="localhost"> <!-- BEGIN realm --> <sometags/> <sometags/> <!-- END realm --> <Host name="localhost" appBase="webapps"/> </Engine> </Service> </Server> realm.xml <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> I want to run a script and have realm.xml replace the contents between the <!-- BEGIN realm --> and <!-- END realm --> lines. If realm.xml changes then whenever the script is run again it will replace the lines again with the new contents of realm.xml. This is intended to be run in /etc/init.d/tomcat on startup of the service on multiple installations on which the realm is going to be different. I'm not so sure how can I do this simply with awk or sed.

    Read the article

  • PHP regex - find and replace

    - by jay
    Hi, I am trying to do this regex match and replace but not able to do it. Example <SPAN class="one">first content here</SPAN> <SPAN class="two">second content here </SPAN> <SPAN class="three">one; two; three; and more.</span> <SPAN class="four">more content here.</span> I want to find each set of the span tags and replace with something like this Find <SPAN class="one">first content here</SPAN> Change to <one>first content here</one> same way the the rest of the span tags. class="one", class="two" and so on are the only key identifier which I use in the regex match expression. So if I find a span tag with these class then I want to do the replace. My main issue is that I am not able to find the occurrence of first closing tag so what it does is it finds from the start to end which is of no use. So far I have been trying to do this using notepad++ but just found that it has its limitations so any php help would be appreciated. regards

    Read the article

  • Replace beginning words(SQL SERVER 2005, SET BASED)

    - by Newbie
    I have the below tables. tblInput Id WordPosition Words -- ----------- ----- 1 1 Hi 1 2 How 1 3 are 1 4 you 2 1 Ok 2 2 This 2 3 is 2 4 me tblReplacement Id ReplacementWords --- ---------------- 1 Hi 2 are 3 Ok 4 This The tblInput holds the list of words while the tblReplacement hold the words that we need to search in the tblInput and if a match is found then we need to replace those. But the problem is that, we need to replace those words if any match is found at the beginning. i.e. in the tblInput, in case of ID 1, the words that will be replaced is only 'Hi' and not 'are' since before 'are', 'How' is there and it is not in the tblReplacement list. in case of Id 2, the words that will be replaced are 'Ok' & 'This'. Since these both words are present in the tblReplacement table and after the first word i.e. 'Ok' is replaced, the second word which is 'This' here comes first in the list of ID category 2 . Since it is available in the tblReplacement, and is the first word now, so this will also be replaced. So the desired output will be Id NewWordsAfterReplacement --- ------------------------ 1 How 1 are 1 you 2 is 2 me My approach so far: ;With Cte1 As( Select t1.Id ,t1.Words ,t2.ReplacementWords From tblInput t1 Cross Join tblReplacement t2) ,Cte2 As( Select Id, NewWordsAfterReplacement = REPLACE(Words,ReplacementWords,'') From Cte1) Select * from Cte2 where NewWordsAfterReplacement <> '' But I am not getting the desired output. It is replacing all the matching words. Urgent help needed*.( SET BASED )* I am using SQL SERVER 2005. Thanks

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >