Search Results

Search found 9872 results on 395 pages for 'preg replace callback'.

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

  • APC UPS replace battery light and apcupsd reporting "replace battery"

    - by mgjk
    We have an APC Smart UPS 1500. The "Replace Battery" light is on, and apcupsd reports: Emergency! Batteries have failed on UPS xxxx. Change them NOW However, from this article, http://sturgeon.apcc.com/kbasewb2.nsf/for+external/f39c4312fcaf7b948525679a005ebb78?OpenDocument it seems that it's not so clear that the UPS battery needs to be replaced. Stranger, according to the information on the UPS, an 11 minute runtime at 42.9% load running at 27.7V isn't so bad. Any thoughts about what to try next? We're a non-profit, money is an object. It would be a shame to replace a battery with a year or so left in it. # apcaccess status APC : 001,041,1017 DATE : Thu Mar 29 13:01:41 EDT 2012 HOSTNAME : oreilly2 VERSION : 3.14.6 (16 May 2009) debian UPSNAME : xxxx CABLE : Custom Cable Smart MODEL : Smart-UPS 1500 UPSMODE : Stand Alone STARTTIME: Thu Mar 29 12:57:30 EDT 2012 STATUS : ONLINE LINEV : 112.3 Volts LOADPCT : 42.9 Percent Load Capacity BCHARGE : 100.0 Percent TIMELEFT : 11.0 Minutes MBATTCHG : 5 Percent MINTIMEL : 3 Minutes MAXTIME : 0 Seconds OUTPUTV : 112.3 Volts SENSE : High DWAKE : -01 Seconds DSHUTD : 090 Seconds LOTRANS : 106.0 Volts HITRANS : 127.0 Volts RETPCT : 000.0 Percent ITEMP : 23.8 C Internal ALARMDEL : Always BATTV : 27.7 Volts LINEFREQ : 60.0 Hz LASTXFER : No transfers since turnon NUMXFERS : 0 TONBATT : 0 seconds CUMONBATT: 0 seconds XOFFBATT : N/A SELFTEST : NO STATFLAG : 0x07000008 Status Flag SERIALNO : AS0603298896 BATTDATE : 2006-01-14 NOMOUTV : 120 Volts NOMBATTV : 24.0 Volts FIRMWARE : 601.3.D USB FW:1.5 APCMODEL : Smart-UPS 1500 END APC : Thu Mar 29 13:02:12 EDT 2012 Error when running upstest You are using a SMART cable type, so I'm entering SMART test mode mode.type = USB_UPS Setting up the port ... Hello, this is the apcupsd Cable Test program. This part of apctest is for testing Smart UPSes. Please select the function you want to perform. 1) Query the UPS for all known values 2) Perform a Battery Runtime Calibration 3) Abort Battery Calibration 4) Monitor Battery Calibration progress 5) Program EEPROM 6) Enter TTY mode communicating with UPS 7) Quit Select function number: 2 First ensure that we have a good link and that the UPS is functionning normally. Simulating UPSlinkCheck ... YWrote: Y Got: getline failed. Apparently the link is not up. Giving up.

    Read the article

  • Replace without the replace function

    - by Molly Potter
    Assignment: Let X and Y be two words. Find/Replace is a common word processing operation that finds each occurrence of word X and replaces it with word Y in a given document. Your task is to write a program that performs the Find/Replace operation. Your program will prompt the user for the word to be replaced (X), then the substitute word (Y ). Assume that the input document is named input.txt. You must write the result of this Find/Replace operation to a file named output.txt. Lastly, you cannot use the replace() string function built into Python (it would make the assignment much too easy). To test your code, you should modify input.txt using a text editor such as Notepad or IDLE to contain different lines of text. Again, the output of your code must look exactly like the sample output. This is my code: input_data = open('input.txt','r') #this opens the file to read it. output_data = open('output.txt','w') #this opens a file to write to. userStr= (raw_input('Enter the word to be replaced:')) #this prompts the user for a word userReplace =(raw_input('What should I replace all occurences of ' + userStr + ' with?')) #this prompts the user for the replacement word for line in input_data: words = line.split() if userStr in words: output_data.write(line + userReplace) else: output_data.write(line) print 'All occurences of '+userStr+' in input.txt have been replaced by '+userReplace+' in output.txt' #this tells the user that we have replaced the words they gave us input_data.close() #this closes the documents we opened before output_data.close() It won't replace anything in the output file. Help!

    Read the article

  • boost bind callback function pointer as a parameter

    - by Takashi-kun
    I am trying to pass a function pointer using boost::bind. void Class::ThreadFunction(Type(*callbackFunc)(message_type::ptr&)) { } boost::shared_ptr<boost::thread> Class::Init(Type(*callbackFunc)(message_type::ptr&)) { return boost::shared_ptr<boost::thread> ( new boost::thread(boost::bind(&Class::ThreadFunction, callbackFunc)) ); } I get the following errors: 1>C:\dev\sapphire\boost_1_46_1\boost/bind/mem_fn.hpp(362) : warning C4180: qualifier applied to function type has no meaning; ignored 1>C:\dev\sapphire\boost_1_46_1\boost/bind/mem_fn.hpp(333) : error C2296: '->*' : illegal, left operand has type 'Type (__cdecl **)(message_type::ptr &)' However, I was able to change to the following, it works fine: void ThreadFunction(Type(*callbackFunc)(message_type::ptr&)) { } boost::shared_ptr<boost::thread> Class::Init(Type(*callbackFunc)(message_type::ptr&)) { return boost::shared_ptr<boost::thread> ( new boost::thread(boost::bind(&ThreadFunction, callbackFunc)) ); } Why do I get those errors if I declare the method in the Class class?

    Read the article

  • FancyBox Callback Keydown

    - by headShrinker
    I have been working on this code, and I can't seem to figure it out. Fancybox's callbacks don't seem to work at all. I have the keyboard bound to the pagination for this gallery. But I want to unbind the keyboard from the table when fancybox opens. When fancybox opens nothing changes.... What to do?? $(document).ready(function() { $('a.active').click(function() { var url = $(this).attr('href'); $('#ajaxTable').load(url+'/1'); return false; }); $("a.fancy").fancybox({ callbackOnStart: function() { $('a#gleft a#gright').unbind("keydown"); }, 'frameWidth': 570, 'frameHeight': 470 }) $(document).keydown(function(event) { if(event.keyCode == 37 ) { var url = $('a#gleft').attr('href'); if (url != null) { $('#ajaxTable').load(url+'/1'); $(document).unbind("keydown"); } } else if(event.keyCode == 39 ) { var url = $('a#gright').attr('href'); if (url != null) { $('#ajaxTable').load(url+'/1'); $(document).unbind("keydown"); } } }); });

    Read the article

  • Python subprocess: callback when cmd exits

    - by Anon
    Hi, I'm currently launching a programme using subprocess.Popen(cmd, shell=TRUE) I'm fairly new to Python, but it 'feels' like there ought to be some api that lets me do something similar to: subprocess.Popen(cmd, shell=TRUE, postexec_fn=function_to_call_on_exit) I am doing this so that function_to_call_on_exit can do something based on knowing that the cmd has exited (for example keeping count of the number of external processes currently running) I assume that I could fairly trivially wrap subprocess in a class that combined threading with the Popen.wait() method, but as I've not done threading in Python yet and it seems like this might be common enough for an API to exist, I thought I'd try and find one first. Thanks in advance :)

    Read the article

  • Macro to improve callback registration readability

    - by Warren Seine
    I'm trying to write a macro to make a specific usage of callbacks in C++ easier. All my callbacks are member functions and will take this as first argument and a second one whose type inherits from a common base class. The usual way to go is: register_callback(boost::bind(&my_class::member_function, this, _1)); I'd love to write: register_callback(HANDLER(member_function)); Note that it will always be used within the same class. Even if typeof is considered as a bad practice, it sounds like a pretty solution to the lack of __class__ macro to get the current class name. The following code works: typedef typeof(*this) CLASS; boost::bind(& CLASS :: member_function, this, _1)(my_argument); but I can't use this code in a macro which will be given as argument to register_callback. I've tried: #define HANDLER(FUN) \ boost::bind(& typeof(*this) :: member_function, this, _1); which doesn't work for reasons I don't understand. Quoting GCC documentation: A typeof-construct can be used anywhere a typedef name could be used. My compiler is GCC 4.4, and even if I'd prefer something standard, GCC-specific solutions are accepted.

    Read the article

  • a script translatable to JavaScript with callback-hell automatic avoider :-)

    - by m1uan
    I looking for "translator" for JavaScript like already is CoffeScript, which will be work for example with forEach (inspired by Groovy) myArray.forEach() -> val, idx { // do something with value and idx } translate to JavaScript myArray.forEach(function(val, idx){ // do something with value and idx }); or something more usefull... function event(cb){ foo()-> err, data1; bar(data1)-> err, data2; cb(data2); } the method are encapsulated function event(cb){ foo(function(err,data1){ bar(data1, function(err, data2) { cb(data2); }); }); } I want ask if similar "compiler" to JavaScript like this even better already doesn't exists? What would be super cool... my code in nodejs looks mostly like this :-) function dealer(cb){ async.parallel([ function(pcb){ async.watterfall([function(wcb){ first(function(a){ wcb(a); }); }, function(a, wcb){ thirt(a, function(c){ wcb(c); }); fourth(a, function(d){ // dealing with “a” as well and nobody care my result }); }], function(err, array_with_ac){ pcb(array_with_ac); }); }, function(pcb){ second(function(b){ pcb(b);}); }], function(err, data){ cb(data[0][0]+data[1]+data[0][1]); // dealing with “a” “b” and “c” not with “d” }); } but, look how beautiful and readable the code could be: function dealer(cb){ first() -> a; second() -> b; third(a) -> c; // dealing with “a” fourth(a) -> d; // dealing with “a” as well and nobody care about my result cb(a+b+c); // dealing with “a” “b” and “c” not with “d” } yes this is ideal case when the translator auto-decide, method need to be run as parallel and method need be call after finish another method. I can imagine it's works Please, do you know about something similar? Thank you for any advice;-)

    Read the article

  • Google local search API - callback never called

    - by Laurent Luce
    Hello, I am trying to retrieve some local restaurants using the LocalSearch Google API. I am initializing the search objects in the OnLoad function and I am calling the searchControl execute function when the user clicks on a search button. The problem is that my function attached to setSearchCompleteCallback never get called. Please let me know what I am doing wrong here. <script src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('maps' , '2'); google.load('search' , '1'); var searcher, searchControl; function OnLoad() { searchControl = new google.search.SearchControl(); searcher = new google.search.LocalSearch(); // create the object // Add the searcher to the SearchControl searchControl.addSearcher(searcher); searchControl.setSearchCompleteCallback(searcher , function() { var results = searcher.results; // Grab the results array // We loop through to get the points for (var i = 0; i < results.length; i++) { var result = results[i]; } }); $('#user_search_address').live('click', function() { g_searchControl.execute('pizza san francisco'); }); } google.setOnLoadCallback(OnLoad); </script>

    Read the article

  • Callback for When jqGrid Finishes Reloading?

    - by James
    Hi, I am using the jqGrid plug-in and at one point I need to refresh the grid and set the selected row to match the record that I am showing in detail on another section of the page. I have the following code but it does not work: $("#AllActions").trigger("reloadGrid").setSelection(selectedRow); The selectedRow parameter comes from an event handler that gets called when the data is changed and the grid needs to be updated. I'm pretty sure that the problem is that the grid is not loaded when the selection is being set, because if I put a call to alert() between the calls to trigger() and setSelection(), it works. I would be grateful for any advice. [Edit]Looks like http://stackoverflow.com/questions/2529581/jqgrids-setselect-does-not-work-after-reloadgrid is related but did not get resolved.[/Edit]

    Read the article

  • Rails - Preventing users from contributing to website when there score is too low - callback / obser

    - by adam
    A User can add a Sentence directly on my website, via twitter or email. To add a sentence they must have a minimum score. If they don't have the minimum score they cant post the sentence and a warning message is either flashed on the website, sent back to them via twitter or email. So I'm wondering how best to code this check. Im thinking a sentence observer. So far my thoughts are in before_create score_sufficient() - score ok = save - score too low = do not save In the case of too low i need to return some flag so that the calling code can then fire off teh relevant warning. What type of flag should I return? False is too ambiguous as that could refer to validation. I could raise an exception but that doesn't sound right or I could return a symbol? Is this even the right approach? What's the best way to code this?

    Read the article

  • jQuery each doesn't have a callback-possibility?

    - by Martti Laine
    Hello I have a loop created with each, check this example: $('.foo').each(function(i){ //do stuff }); Is there any possibility to run a functions when this loop has ended? Couldn't find it on docs or Google. I can make it work without this kind of solution, but it's always good to search for and use the simpliest methods. Martti Laine

    Read the article

  • Avoid stuck calling callback

    - by andlomba
    Hello all, This is a question about generic c++ event driven applications design. Lets assume that we have two threads, a "Dispatcher" (or "Engine"...) and a "Listener" (or "Client"...). Let's assume that I write the Dispatcher code, and release it as a library. I also write the Listener interface, of course. When the Dispatcher executes (after Listener registration) listenerInstance.onSomeEvent(); the event handling code will actually be executed by the Dispatcher thread, so if the person that implements the Listener writes something like void Listener::onSomeEvent() { while(true) ; } The Dispatcher will stuck forever. Is there a "plain old c++" (I mean no boost or libsigc++) way to "decouple" the two classes, so I can be sure that my Dispatcher will work fine whatever the Listeners does in the callbacks? bye and thanks in advance, Andrea

    Read the article

  • callback function for php preg_replace_callback not getting called on linux CentOS 5.4

    - by user105165
    I have used the preg_replace_callback as $string = preg_replace_callback($pattern,'CreateTemplatesController::callbackhandler',$string ); I have called the callbackhandler function with the class name as this function is a private static function. Problem is "callbackhandler" function is not getting called. Please post if any one know the reason for the same. Thanks in Advance

    Read the article

  • Does submit() function has a callback?

    - by ecu
    Hi, I have this code: setMyCookie('name','value_1'); $('.myform').submit(); setMyCookie('name','value_2'); Problem: Webkit browsers seem to update 'MyCookie' with 'value_2' before the form gets submited, or in the exact moment it is being submited, so wrong cookie value is sent with it. I want to change cookie value to 'value_2' immediately after the form is submited so the cookie is ready for another request. The following code works fine, but I don't think using timeout() is the best solution. Maybe there is another way to solve this problem? setMyCookie('name','value_1'); $('.myform').submit(); setTimeout(function(){setMyCookie('name',value_2);},100); Thanks.

    Read the article

  • Prototype with a callback problem

    - by Lisio
    function Foo() { this.bar = false; } Foo.prototype={ onLoad: function() { this.bar=true; }, create: function(id) { SomeClass.someMethod({ id: id, onWorkIsDone: this.onLoad }); } }; var temp=new Foo(); temp.create(); This sample has a logic error in string 'onWorkIsDone: this.onLoad'. What I have to place instead of 'this.onLoad' to make SomeClass call exactly the temp.onLoad method when it finishes it's work?

    Read the article

  • Search for index.php and index.html and replace string

    - by Jonas
    Hello. I recently had some sort of Malware on my computer that added to all index.php and index.html ON THE WEBSERVER! the following string(s): echo "<iframe src=\"http://fabujob.com/?click=AD4A4\" width=1 height=1 style=\"visibility:hidden;position:absolute\"></iframe>"; echo "<iframe src=\"http://fabujob.com/?click=AC785\" width=1 height=1 style=\"visibility:hidden;position:absolute\"></iframe>"; So the parameter after "click=" always changes. These two were only examples. Is there a way to do that quick and fast? . . EDIT: It is on my webserver, so no use of find...

    Read the article

  • UNIX command for replace files

    - by all-R
    Hi, on Mac, you know there is no 'merge files' when you command+c/command+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

  • MySQL/Apache: Replace spaces with underscores only in certain URLs

    - by javipas
    I'm having a problem with some images I'm using on my WordPress blog. After a migration I renamed every image replacing spaces with underscores, so HIDDEN_264_4062_FOTO_IDF los MID.jpg was renamed to HIDDEN_264_4062_FOTO_IDF_los_MID.jpg But althought the trick was necessary and worked for most of the posts, some of them try to find the old image, with spaces: This is not found http://www.example.com/files/HIDDEN_264_4062_FOTO_IDF%20los%20MID.jpg and this should be the right URL http://www.example.com/files/HIDDEN_264_4062_FOTO_IDF_los_MID.jpg Careful, though, 'cause the "%20" is only shown on the browser: the text on the database shows spaces, not "%20". I'd like to know if maybe I could make a SQL query in my WordPress MySQL database that replaces spaces in .jpg files with underscores. The path of the images is always the same, so the rule should transform this: /files/HIDDEN_264_4062_FOTO_IDF los MID.jpg /files/HIDDEN_264_4062_FOTO_IDF_los_MID.jpg the "/files/HIDDEN_264_" part is always the same, but the rest varies. Is some way to perform this? Maybe a rewrite rule on Apache (our current webserver)?

    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

  • 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

  • Using TextboxList events and callbacks

    - by Wraith
    Has anyone gotten callbacks working with Guillermo Rauch's TextboxList Autocomplete? I've tried multiple ways to bind and multiple events (e.g. hover) - nothing seems to register. $('#entSearch').textboxlist({unique: true, plugins: { autocomplete: { minLength: 3, queryRemote: true, placeholder: false, remote: { url: "{{=URL(r=request, f='call/json/suggest')}}", extraParams: {type: "", guid: ""} } } }, onHover: function(token) { alert('hover 1'); } }); $('#entSearch').hover(function() { alert('hover 2'); }); $('#entSearch').bind('hover', function() { alert('hover 3'); });

    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

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