Search Results

Search found 53464 results on 2139 pages for 'find and replace'.

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

  • find directories in the current directory, older than 5 days and archive them

    - by user197284
    This is basic questions. I need to find folders in the current working directory(not recursively) and if they are older than 5 days archive them. zip or tar.gz is fine. I can find the folders with following commands find ./ -maxdepth 1 -type d -mtime +5 And i know i can pass this output of the find using xargs. But i do not know how to archive with folder name intact. That is the directory test1 should be archived to test1.zip and directory "test2" should be archived to "test2.zip". Any inputs are welcome. Regards

    Read the article

  • mac replace, what is the unix command?

    - by all-R
    Hi, on Mac, you know there is no 'merge files' when you ctrl+c/ctrl+v some folder on another one, it actually replaces it. I'm simply wondering on what UNIX is this based? because correct me if I'm wrong, but "cp - R" DOES merge files, no? And that's what I'm doing via the Finder, copying some files and folders... thanks!

    Read the article

  • Linux find command gotcha?

    - by rabbit
    Hi I am trying to find all js & css files in one find command. I tried all of the below but in vain: find WebContent -name "*.[jc]ss?" find WebContent -name "*.[jc]ss{0,1}" find WebContent -name "*.[jc][s]{1,2}$" find WebContent -name "*.[jc]s{1,2}" find WebContent -name "*.[jc]s[s]?" Now what??

    Read the article

  • Is there a way to pass another parameter in the preg_replace_callback callback function?

    - by DaNieL
    mmmh guys, i really hope my english is good enaught to explain what i need. Lets take this example (that is just an example!) of code: class Something(){ public function Lower($string){ return strtolower($string); } } class Foo{ public $something; public $reg; public $string; public function __construct($reg, $string, $something){ $this->something = $something; $this->reg = $reg; $this->string = $string; } public function Replace(){ return preg_replace_callback($this->reg, 'Foo::Bar', $this->string); } public static function Bar($matches){ /* * [...] * do something with $matches and create the $output variable * [...] */ /* * I know is really useless in this example, but i need to have an istance to an object here * (in this example, the Something object, but can be something else!) */ return $this->something->Lower($output); } } $s = new Something(); $foo = new Foo($myregexp, $mystring, $s); $content = $foo->Replace(); So, the php manual say that to use a class method as callback in preg_replace_callback(), the method must be abstract. I need to pass an instance of a previuosly initialized object (in the example, an instance of the Something class) at the callback function. I tryed to use call_user_func(), but doesnt work (becose in this way i miss the matches parameter). Is there a way to do that, or have i to separate the process (doing before preg_match_all, for each match retrieve the replace value, and then a simple preg_replace)?

    Read the article

  • Python refuses text.replace() in one environment

    - by gx
    Hi fellow programmers, I've been mocking about with the following bit of dirty support-code for a pylons app, which works fine in a python-shell, a separate python file, or when running in paster. Now, we've put the application on-line through mod_wsgi and apache and this specific piece of code stopped working completely. First off, the code itself: def fixStyle(self, text): t = text.replace('<p>', '<p style="%s">' % (STYLEDEF,)) t = t.replace('class="wide"', 'style="width: 125px; %s"' % (DEFSTYLE,)) t = t.replace('<td>', '<td style="%s">' % (STYLEDEF,)) t = t.replace('<a ', '<a style="%s" ' % (LINKSTYLE,)) return t It seems pretty straightforward, and to be honest, it is. So what happens when I put a piece of text in it, for example: <table><tr><td>Test!</td></tr></table> The output should be: <table><tr><td style="stuff-from-styledef">Test!</td></tr></table> and it is, on most systems. When we put it through the app on Apache/mod_wsgi though, the following happens: <table><tr><td>Test!</td></tr></table> You guessed it. I'm currently at a loss and have no idea where to go next. Googling doesn't really work out, so I'm hoping on you guys to help out and perhaps point out a fundamental issue with using whatever-is-causing-this. If anything is missing I'll edit it in.

    Read the article

  • Regex - find and replace complete string occurrences only (not partial matches)

    - by vittore
    I'm not very good at regex but maybe there's a simple way to achieve this task. I'm given a string like "bla @a bla @a1 bla" I'm also given pairs like {"a", "a2"} , {"a1", "a13"}, and I need to replace @a with @a2 for the first pair, and @a1 with @a13 for the second one. The problem is when i use String.Replace and look for @a, it also replaces @a1 but it should not. I need it to completely match @a and avoid partially matching it in other places. Note: the given string could also be brackets, commas, dots and so on. However, pairs will always be [a-z]*[0-9]+ Help me with regex replace, please. Cheers

    Read the article

  • Need help modifying my Custom Replace code based on string passed to it

    - by fraXis
    Hello, I have a C# program that will open a text file, parse it for certain criteria using a RegEx statement, and then write a new text file with the changed criteria. For example: I have a text file with a bunch of machine codes in it such as: X0.109Y0Z1.G0H2E1 My C# program will take this and turn it into: X0.109Y0G54G0T3 G43Z1.H2M08 (Note: the T3 value is really the H value (H2 in this case) + 1). T = H + 1 It works great, because the line usually always starts with X so the RegEx statement always matches. My RegEx that works with my first example is as follows: //Regex pattern for: //- X(value)Y(value)Z(value)G(value)H(value)E(value) //- X(value)Y(value)Z(value)G(value)H(value)E(value)M(value) //- X(value)Y(value)Z(value)G(value)H(value)E(value)A(value) //- X(value)Y(value)Z(value)G(value)H(value)E(value)M(value)A(value) //value can be positive or negative, integer or floating point number with multiple decimal places or without any private Regex regReal = new Regex("^(X([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(Y([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(Z([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(G([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(H([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(E([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(M([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*)?(A([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*)?$"); This RegEx works great because sometimes the line of code could also have an M or A at the end such as: X0.109Y0Z1.G0H2E1A2 My problem is now I have run into some lines of code that have this: G90G0X1.5Y-0.036E1Z3.H1 and I need to turn it into this: G90G0X1.5Y-0.036G54T2 G43Z3.H1M08 Can someone please modify my RegEx and code to turn this: G90G0X1.5Y-0.036E1Z3.H1 into: G90G0X1.5Y-0.036G54T2 G43Z3.H1M08 But sometimes the values could be a little different such as: G(value)G(value)X(value)Y(value)E(value)Z(value)H(value) G(value)G(value)X(value)Y(value)E(value)Z(value)H(value)A(value) G(value)G(value)X(value)Y(value)E(value)Z(value)H(value)A(value)(M)value G(value)G(value)X(value)Y(value)E(value)Z(value)H(value)M(value)(A)value But also (this is where Z is moved to a different spot) G(value)G(value)X(value)Y(value)Z(value)E(value)H(value) G(value)G(value)X(value)Y(value)Z(value)E(value)H(value)A(value) G(value)G(value)X(value)Y(value)Z(value)E(value)H(value)A(value)(M)value G(value)G(value)X(value)Y(value)Z(value)E(value)H(value)M(value)(A)value Here is my code that needs to be changed (I did not include the open and saving of the text file since that is pretty standard stuff). //Regex pattern for: //- X(value)Y(value)Z(value)G(value)H(value)E(value) //- X(value)Y(value)Z(value)G(value)H(value)E(value)M(value) //- X(value)Y(value)Z(value)G(value)H(value)E(value)A(value) //- X(value)Y(value)Z(value)G(value)H(value)E(value)M(value)A(value) //value can be pozitive or negative, integer or floating point number with multiple decimal places or without any private Regex regReal = new Regex("^(X([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(Y([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(Z([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(G([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(H([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(E([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*){1}(M([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*)?(A([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*)?$"); private string CheckAndModifyLine(string line) { if (regReal.IsMatch(line)) //Check the first Regex with line string { return CustomReplace(line); } else { return line; } } private string CustomReplace(string input) { string returnValue = String.Empty; int zPos = input.IndexOf("Z"); int gPos = input.IndexOf("G"); int hPos = input.IndexOf("H"); int ePos = input.IndexOf("E"); int aPos = input.IndexOf("A"); int hValue = Int32.Parse(input.Substring(hPos + 1, ePos - hPos - 1)) + 1; //get H number //remove A value returnValue = ((aPos == -1) ? input : input.Substring(0, aPos)); //replace Z value returnValue = Regex.Replace(returnValue, "Z[-]?\\d*\\.*\\d*", "G54"); //replace H value returnValue = Regex.Replace(returnValue, "H\\d*\\.*\\d*", "T" + hValue.ToString() + ((aPos == -1) ? String.Empty : input.Substring(aPos, input.Length - aPos))); //replace E, or E and M value returnValue = Regex.Replace(returnValue, "E\\d*\\.*\\d(M\\d*\\.*\\d)?", Environment.NewLine + "G43" + input.Substring(zPos, gPos - zPos) + input.Substring(hPos, ePos - hPos) + "M08"); return returnValue; } I tried to modify the above code to match the new line of text I am encountering (and split into two lines like my first example) but I am failing miserably. Thanks so much.

    Read the article

  • String replace in C#

    - by ile
    I'd like to use this method to create user-friendly URL. Because my site is in Croatian, there are characters that I wouldn't like to strip but replace them with another. Fore example, this string: ŠÐCŽ šdccž needs to be: sdccz-sdccz So, I would like to make two arrays, one that will contain characters that are to be replaced and other array with replacement characters: string[] character = { "Š", "Ð", "C", "C", "Ž", "š", "d", "c", "c", "ž" }; string[] characterReplace = { "s", "d", "c", "c", "z", "s", "d", "c", "c", "z" }; Finally, this two arrays should be use in some method that will take string, find matches and replace them. In php I used preg_replace function to deal with this. In C# this doesn't work: s = Regex.Replace(s, character, characterReplace); Would appreciate if someone could help. Thanks

    Read the article

  • string replace in file using C

    - by Hristo
    I haven't yet implemented this, I'm still in the thinking stage, but I have to go through a file and replace a certain string with another string. For example, <img src="/images/logo.gif" ... should become <img src="/proxy/www.example.com/images/logo.gif" ... Any advice on how I can approach this? Perhaps there exist some "string replace" C functions that would do this for me that I don't know about...? Right now, if I had to write this function myself, I would give it as parameters the file, string to replace, replacement string. Then I would manually go through the file and look for an occurrence of the string and recreate it. This, however, seems very inefficient. Are there better ways to do this? Thanks, Hristo

    Read the article

  • javascript replace div tags for p tags where it has no class

    - by Tom
    I would like to replace div tags for p tags but only when the div tag does not have a class. So this: <div class="myDiv"> <div>sdfglkhj sdfgkhl sdfkhgl sdf</div> <div>dsf osdfghjksdfg hsdfg</div> </div> Would become: <div class="myDiv"> <p>sdfglkhj sdfgkhl sdfkhgl sdf</p> <p>dsf osdfghjksdfg hsdfg</p> </div> I've tried .replace("<div>", "<p>").replace("</div>","</p>") but this replaces the closing tag of the one with a class.

    Read the article

  • Smiley Replace within CDATA of an HTML-String

    - by michaelm
    Hello, i have got a simple problem :( I need to replace text smilies with the according smiley-image. ok.. thats not really complex, but now i have to replace only smilie appereances outside of HTML Tags. short examplae: Text: Thats a good example :/ .. with a <a href="http://www.foobar.com">link</a> inside. i want to replace ":/" with the image of this smiley... ok, how to do that the best way?

    Read the article

  • Find&Replace using Python - Binary file

    - by Aaron Hoffman
    Hello, I'm attempting to do a "find and replace" in a file on a Mac OS X computer. Although it appears to work correctly. It seems that the file is somehow altered. The text editor that I use (Text Wrangler) is unable to even open the file once this is completed. Here is the code as I have it: import fileinput for line in fileinput.FileInput("testfile.txt",inplace=1): line = line.replace("newhost",host) print line, When I view the file from the terminal, it does say "testfile" may be a binary file. See it anyway? Is there a chance that this replace is corrupting the file? Do I have another option for this to work? I really appreciate the help. Thank you, Aaron UPDATE: the actual file is NOT a .txt file it is a .plist file which is preference file in Mac OS X if that makes any difference

    Read the article

  • Replace several tags from a text js

    - by Blanca
    Hi! I have this pice of text I would like to change: [¿Cómo se procede cuando la mujer o pareja de un < bfallecido< /b pide la congelación del semen] So I would like to remove ], [ and < b< /b Is there any way to change it everything in the same time?? I tried: function replaceThings(){ jQuery(".summary").each(function(){ var t = jQuery(this).text(); jQuery(this).text(t.replace(/& lt;/g, '')); jQuery(this).text(t.replace('[', '')); jQuery(this).text(t.replace(']', '')); }); But only replaces ]. Thanks in advance

    Read the article

  • python: find and replace numbers < 1 in text file

    - by hjp
    I'm pretty new to Python programming and would appreciate some help to a problem I have... Basically I have multiple text files which contain velocity values as such: 0.259515E+03 0.235095E+03 0.208262E+03 0.230223E+03 0.267333E+03 0.217889E+03 0.156233E+03 0.144876E+03 0.136187E+03 0.137865E+00 etc for many lines... What I need to do is convert all the values in the text file that are less than 1 (e.g. 0.137865E+00 above) to an arbitrary value of 0.100000E+01. While it seems pretty simple to replace specific values with the 'replace()' method and a while loop, how do you do this if you want to replace a range? thanks

    Read the article

  • Saving substrings using Regular Expressions

    - by user362971
    I'm new to regular expressions in Java (or any language, for that matter) and I'm wanting to do a find using them. The tricky part that I don't understand how to do is replace something inside the string that matches. For example, if the line I'm looking for is Person item6 [can {item thing [wrap]}] I'm able to write a regex that finds that line, but finding what the word "thing" is (as it may differ among different lines) is my problem. I may want to either replace that word with something else or save it in a variable for later. Is there any easy way to do this using Java's regex engine?

    Read the article

  • Smart auto detect and replace URLs with anchor tags

    - by Robert Koritnik
    I've written a regular expression that automatically detects URLs in free text that users enter. This is not such a simple task as it may seem at first. Jeff Atwood writes about it in his post. His regular expression works, but needs extra code after detection is done. I've managed to write a regular expression that does everything in a single go. This is how it looks like (I've broken it down into separate lines to make it more understandable what it does): 1 (?<outer>\()? 2 (?<scheme>http(?<secure>s)?://)? 3 (?<url> 4 (?(scheme) 5 (?:www\.)? 6 | 7 www\. 8 ) 9 [a-z0-9] 10 (?(outer) 11 [-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+(?=\)) 12 | 13 [-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+ 14 ) 15 ) 16 (?<ending>(?(outer)\))) As you may see, I'm using named capture groups (used later in Regex.Replace()) and I've also included some local characters (cšžcd), that allow our localised URL to be parsed as well. You can easily omit them if you'd like. Anyway. Here's what it does (referring to line numbers): 1 - detects if URL starts with open braces (is contained inside braces) and stores it in "outer" named capture group 2 - checks if it starts with URL scheme also detecting whether scheme is SSL or not 3 - starts parsing URL itself (will store it in "url" named capture group) 4-8 - if statement that says: if "sheme" was present then www. part is optional, otherwise mandatory for a string to be a link (so this regular expression detects all strings that start with either http or www) 9 - first character after http:// or www. should be either a letter or a number (this can be extended if you would like to cover even more links, but I've decided to omit other characters because I can't remember a link that would start with some other character 10-14 - if statement that says: if "outer" (braces) was present capture everything up to the last closing braces otherwise capture all 15 - closes the named capture group for URL 16 - if open braces was present, capture closing braces as well and store it in "ending" named capture group First and last line used to have \s* in them as well, so user could also write open braces and put a space inside before pasting link. Anyway. My code that does link replacement with actual anchor HTML elements looks exactly like this: value = Regex.Replace( value, @"(?<outer>\()?(?<scheme>http(?<secure>s)?://)?(?<url>(?(scheme)(?:www\.)?|www\.)[a-z0-9](?(outer)[-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+(?=\))|[-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+))(?<ending>(?(outer)\)))", "${outer}<a href=\"http${secure}://${url}\">http${secure}://${url}</a>${ending}", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); As you can see I'm using named capture groups to replace link with an Anchor tag: ${outer}<a href=\"http${secure}://${url}\">http${secure}://${url}</a>${ending} I could as well omit the http(s) part in anchor display to make links look friendlier, but for now I decided not to. Question I would like for my links to be replaced with shortenings as well. So when user copies a very long links (for instance if they would copy a link from google maps that usually generates long links I would like to shorten the visible part of the anchor tag. Link would work, but visible part of an anchor tag would be shortened to some number of characters. Does the replace string support notations like that so I can stil use a singe Regex.Replace() call?

    Read the article

  • Using Find, Grep, Awk, or Sed To Rename Server After Cloning

    - by ServerChecker
    My client tells me they have cloned a VM in VMWare of an Ubuntu Linux server. Now it's my job to get into all the files and find out what still has the old server name of "bishop" and change it to something else. Also, the IP address is changed and I need to search for that too. How would you typically use find, grep, awk, or sed to find these files and then change them rapidly? In the end, I want to make a Bash script. Of course, I'm not expecting you to tell me every file, but just want to know the technique for finding files with "x" in it and then switching that rapidly with "y".

    Read the article

  • Print full path of files and sizes with find in Linux

    - by cat pants
    Here are the specs: Find all files in / modified after the modification time of /tmp/test, exclude /proc and /sys from the search, and print the full path of the file along with human readable size. Here is what I have so far: find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -exec ls -lh {} \; | less The issue is that the full path doesn't get printed. Unfortunately, ls doesn't support printing the full path! And all solutions I have found that show how to print the full path suggest using find. :| Any ideas? Thanks!

    Read the article

  • How do I find and replace 'whole words only', in Microsoft Word?

    - by user277816
    I want to be able to find and replace eat with Eat in Microsoft Word 2007. However, I don’t want to replace every occurrence of eat such as those that can be found inside other words such as great and meat. I have tried doing this using the regular Find and Replace tool, but I get words with capital letters in the middle. Is there a way I can just replace eat with Eat if it only exists on its own?

    Read the article

  • Regex.Replace only replaces start of string

    - by Yannick Smits
    I'm trying to replace a friendly url pattern with a html url notation but due to lack of regex experience I can't figure out why my regex only replaces the first occurence of my pattern: string text = "[Hotel Des Terrasses \http://flash-hotel.fr/] and [Du Phare \http://www.activehotels.com/hotel/]"; text = Regex.Replace(text, @"\[(.+)\s*\\(.+)\]", "<a href=\"$2\" target=\"_blank\">$1</a>"); How can i make the second pattern be replaced with the HTML markup too?

    Read the article

  • .NET string replace russian to english

    - by Fabio Beoni
    I have a strange problem replacing chars in string... I read a .txt file containing russian text, and starting from a list of letters russian to english (ru=en), I loop the list and I WOULD like to replace russian characters with english characters. The problem is: I can see in the debug the right reading of the russian and the right reading of the english, but using myWord = myWord.Replace(ruChar, enChar), the string is not replaced. My txt file is a UTF-8 encoding.

    Read the article

  • visual studio Regex Find/Replace error

    - by rockinthesixstring
    I'm working on using Find/Replace to change a bunch of labels to DataBound text. Here's my regex <asp:Label ID="lbl{\d*}" runat="server" /> Here's my replace <%# Eval("\1")%> Here's my Error Unknown argument for ':' operator. Complete Regular Expression required in the search string. How would I resolve this?

    Read the article

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