Search Results

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

Page 14/395 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Replace a fragment programmatically

    - by Vishal
    I have three fragments as shown in below figure. I have added all these three fragments in LinearLayout using .xml file and when my launcher activity starts I load that .xml layout using setContentView.I have some controls on fragment2. Clicking on any one loads the fragment4 programmatically using FragmentTransaction and commit method. This fragments is added to the screen but the problem is it take the whole screen area. What can be the problem?

    Read the article

  • text replace with regex in sqlserver

    - by Thiyaneshwaran S
    Currently i have sql-server nvarchar(max) column which has text that starts with """ The only thing that varies in the pattern is the < in the class name. The common part is "" Some sample values are "" "" "" All the These span text are present only at the beginning of the column. Any such matching span in the middle should not be removed or matched. Whats the sql server query with regex to remove all these occurance of span?

    Read the article

  • Using preg_replace to replace all occurrences in php

    - by Greg-J
    Regex is absolutely my weak point and this one has me completely stumped. I am building a fairly basic search functionality and I need to be able to alter my user input based on the following pattern: Subject: %22first set%22 %22second set%22-drupal -wordpress Desired output: +"first set" +"second set" -drupal -wordpress I wish I could be more help as I normally like to at least post the solution I have so far, but on this one I'm at a loss. Any help is appreciated. Thank you.

    Read the article

  • Regex to replace 'li' with 'option' without losing class and id attributes

    - by Earthman Web
    I am looking for a solution using preg_replace or similar method to change: <li id="id1" class="authorlist" /> <li id="id2" class="authorlist" /> <li id="id3" class="authorlist" /> to <option id="id1" class="authorlist" /> <option id="id2" class="authorlist" /> <option id="id3" class="authorlist" /> I think I have the pattern correct, but not sure how to do the replacement part... Here is the (wordpress) php code: $string = wp_list_authors( $args ); //returns list as noted above $pattern = '<li ([^>]*)'; $replacement = '?????'; echo preg_replace($pattern, $replacement, $string); Suggestions, please?

    Read the article

  • php search and replace first element in div

    - by cnotethegr8
    i have a structure that looks like this <div class="table"> <div> <p> name1 </p> <p> title1 </p> </div> <div> <p> name2 </p> <p> title2 </p> </div> <div> <p> name3 </p> <p> title3 </p> </div> </div> and it continues a few hundred more times. what can i write in php that will search ( class="table" div ) and add a class to only the first 'p' in each 'div'?

    Read the article

  • Text replace with regex in SQL Server

    - by Thiyaneshwaran S
    Currently I have a SQL server column of type nvarchar(max) which has text that starts with <span class="escape_<<digits>>"></span> The only thing that varies in the pattern is the <<digits>> in the class name. The common part is <span class="myclass_ and the closing </span> Some sample values are <span class="myclass_12"></span> <span class="myclass_234"></span> <span class="myclass_4546"></span> These span text are present only at the beginning of the column. Any such matching span in the middle should not be removed or matched. Whats the SQL Server query with regex to remove all these occurances of span?

    Read the article

  • VIM Replace word with contents of paste buffer?

    - by plong
    I need to do a bunch of word replacements in a file and want to do it with a vi command, not an EX command such as :%s///g. I know that this is the typical way one replaces the word at the current cursor position: cw<text><esc> but is there a way to do this with the contents of the unnamed register as the replacement text and without overwriting the register?

    Read the article

  • Replace a whole line in a txt file

    - by user302935
    I'am new to Python 3 and could really use a little help. I have a txt file containing: InstallPrompt= DisplayLicense= FinishMessage= TargetName=D:\somewhere FriendlyName=something I have a python script that in the end, should change just two lines to: TargetName=D:\new FriendlyName=Big Could anyone help me, please? I have tried to search for it, but I didnt find something I could use. The text that should be replaced could have different length.

    Read the article

  • Replace non-html links with <A> tags

    - by tombazza
    I have a block of code that will take a block of text like the following: Sample text sample text http://www.google.com sample text Using the preg_replace_callback method and the following regular expression: preg_replace_callback('/http:\/\/([,\%\w.\-_\/\?\=\+\&\~\#\$]+)/', create_function( '$matches', '$url = $matches[1]; $anchorText = ( strlen($url) > 35 ? substr($url, 0, 35).\'...\' : $url); return \'<a href="http://\'. $url .\'">\'. $anchorText .\'</a>\';'), $str); Will convert the sample text to look like: Sample text sample text < a href="http://www.google.com"http://www.google.com< /a sample text My problem now is that we have introduced a rich text editor that can create links before being sent to the script. I need to update this piece of code so that it will ignore any URLs that are already inside an tag.

    Read the article

  • Back-to-back ajax long poll without a recursive callback function.

    - by Teddy
    I'm trying to make long poll ajax calls, back to back. The problem with the current way I'm doing it is that I make each successive call from the callback function of the previous call. Is this a problem? Firebug doesn't show any of my ajax calls as completed, even thought the data is returned and the callback is executed. The recursive structure seems inefficient. Any ideas?

    Read the article

  • How to design 2D collision callback methods?

    - by Ahmed Fakhry
    In a 2D game where you have a lot of possible combination of collision between objects, such as: object A vs object B = object B vs A; object A vs object C = object C vs A; object A vs object D = object D vs A; and so on ... Do we need to create callback methods for all single type of collision? and do we need to create the same method twice? Like, say a bullet hits a wall, now I need a method to penetrate the wall for the wall, and a method to destroy the bullet for the bullet!! At the same time, a bullet can hit many objects in the game, and hence, more different callback methods!!! Is there a design pattern for that?

    Read the article

  • Get div and the correct close tag preg

    - by Barkermn01
    hi all, Now preg has always been a tool to me that i like but i cant figure out for the life if me if what i want to do is possible let and how to do it is going over my head What i want is preg_match to be able to return me a div's innerHTML the problem is the div im tring to read has more divs in it and my preg keeps closing on the first tag it find Here is my Actual code $scrape_address = "http://isohunt.com/torrent_details/133831593/98e034bd6382e0f4ecaa9fe2b5eac01614edc3c6?tab=summary"; $ch = curl_init($scrape_address); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, '1'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_ENCODING, ""); $data = curl_exec($ch); preg_match('% <div id="torrent_details">(.*)</div> %six', $data, $match); print_r($match); This has been updated for TomcatExodus's help Live at :: http://megatorrentz.com/beta/details.php?hash=98e034bd6382e0f4ecaa9fe2b5eac01614edc3c6

    Read the article

  • C# Regex - Replace multiple characters at once without overwriting?

    - by Everaldo Aguiar
    Hello guys, I'm implementing a c# program that should automatize a Mono-alphabetic substitution cipher. The functionality i'm working on at the moment is the simplest one: The user will provide a plain text and a cipher alphabet, for example: Plain text(input): THIS IS A TEST Cipher alphabet: A - Y, H - Z, I - K, S - L, E - J, T - Q Cipher Text(output): QZKL KL QJLQ I thought of using regular expressions since I've been programming in perl for a while, but I'm encountering some problems on c#. First I would like to know if someone would have a suggestion for a regular expression that would replace all occurrence of each letter by its corresponding cipher letter (provided by user) at once and without overwriting anything. Example: In this case, user provides plaintext "TEST", and on his cipher alphabet, he wishes to have all his T's replaced with E's, E's replaced with Y and S replaced with J. My first thought was to substitute each occurrence of a letter with an individual character and then replace that character by the cipherletter corresponding to the plaintext letter provided. Using the same example word "TEST", the steps taken by the program to provide an answer would be: 1 - replace T's with (lets say) @ 2 - replace E's with # 3 - replace S's with & 4 - Replace @ with E, # with Y, & with j 5 - Output = EYJE This solution doesn't seem to work for large texts. I would like to know if anyone can think of a single regular expression that would allow me to replace each letter in a given text by its corresponding letter in a 26-letter cipher alphabet without the need of splitting the task in an intermediate step as I mentioned. If it helps visualize the process, this is a print screen of my GUI for the program: http://img43.imageshack.us/img43/2118/11618743.jpg

    Read the article

  • .NET Regex - Replace multiple characters at once without overwriting?

    - by Everaldo Aguiar
    I'm implementing a c# program that should automatize a Mono-alphabetic substitution cipher. The functionality i'm working on at the moment is the simplest one: The user will provide a plain text and a cipher alphabet, for example: Plain text(input): THIS IS A TEST Cipher alphabet: A - Y, H - Z, I - K, S - L, E - J, T - Q Cipher Text(output): QZKL KL QJLQ I thought of using regular expressions since I've been programming in perl for a while, but I'm encountering some problems on c#. First I would like to know if someone would have a suggestion for a regular expression that would replace all occurrence of each letter by its corresponding cipher letter (provided by user) at once and without overwriting anything. Example: In this case, user provides plaintext "TEST", and on his cipher alphabet, he wishes to have all his T's replaced with E's, E's replaced with Y and S replaced with J. My first thought was to substitute each occurrence of a letter with an individual character and then replace that character by the cipherletter corresponding to the plaintext letter provided. Using the same example word "TEST", the steps taken by the program to provide an answer would be: 1 - replace T's with (lets say) @ 2 - replace E's with # 3 - replace S's with & 4 - Replace @ with E, # with Y, & with j 5 - Output = EYJE This solution doesn't seem to work for large texts. I would like to know if anyone can think of a single regular expression that would allow me to replace each letter in a given text by its corresponding letter in a 26-letter cipher alphabet without the need of splitting the task in an intermediate step as I mentioned. If it helps visualize the process, this is a print screen of my GUI for the program:

    Read the article

  • jQuery HOW TO?? pass additional parameters to success callback for $.ajax call ?

    - by dotnetgeek
    Hello jQuery Ninjas! I am trying, in vain it seems, to be able to pass additional parameters back to the success callback method that I have created for a successful ajax call. A little background. I have a page with a number of dynamically created textbox / selectbox pairs. Each pair having a dynamically assigned unique name such as name="unique-pair-1_txt-url" and name="unique-pair-1_selectBox" then the second pair has the same but the prefix is different. In an effort to reuse code, I have crafted the callback to take the data and a reference to the selectbox. However when the callback is fired the reference to the selectbox comes back as 'undefined'. I read here that it should be doable. I have even tried taking advantage of the 'context' option but still nothing. Here is the script block that I am trying to use: <script type="text/javascript" language="javascript"> $j = jQuery.noConflict(); function getImages(urlValue, selectBox) { $j.ajax({ type: "GET", url: $j(urlValue).val(), dataType: "jsonp", context: selectBox, success:function(data){ loadImagesInSelect(data, $j(this)) } , error:function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); } }); } function loadImagesInSelect(data, selectBox) { //var select = $j('[name=single_input.<?cs var:op_unique_name ?>.selImageList]'); var select = selectBox; select.empty(); $j(data).each(function() { var theValue = $j(this)[0]["@value"]; var theId = $j(this)[0]["@name"]; select.append("<option value='" + theId + "'>" + theValue + "</option>"); }); select.children(":first").attr("selected", true); } From what I have read, I feel I am close but I just cant put my finger on the missing link. Please help in your typical ninja stealthy ways. TIA

    Read the article

  • C# webservice async callback not getting called on HTTP 407 error.

    - by Ben
    Hi, I am trying to test the use-case of a customer having a proxy with login credentials, trying to use our webservice from our client. If the request is synchronous, my job is easy. Catch the WebException, check for the 407 code, and prompt the user for the login credentials. However, for async requests, I seem to be running into a problem: the callback is never getting called! I ran a wireshark trace and did indeed see that the HTTP 407 error was being passed back, so I am bewildered as to what to do. Here is the code that sets up the callback and starts the request: TravelService.TravelServiceImplService svc = new TravelService.TravelServiceImplService(); svc.Url = svcUrl; svc.CreateEventCompleted += CbkCreateEventCompleted; svc.CreateEventAsync(crReq, req); And the code that was generated when I consumed the WSDL: public void CreateEventAsync(TravelServiceCreateEventRequest CreateEventRequest, object userState) { if ((this.CreateEventOperationCompleted == null)) { this.CreateEventOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateEventOperationCompleted); } this.InvokeAsync("CreateEvent", new object[] { CreateEventRequest}, this.CreateEventOperationCompleted, userState); } private void OnCreateEventOperationCompleted(object arg) { if ((this.CreateEventCompleted != null)) { System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); this.CreateEventCompleted(this, new CreateEventCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); } } Debugging the WS code, I found that even the SoapHttpClientProtocol.InvokeAsync method was not calling its callback as well. Am I missing some sort of configuration?

    Read the article

  • Can't grab foreign key during after_create callback because it doesn't exist yet!

    - by Randy
    I have some models all linked together in memory (parent:child:child:child) and saved at the same time by saving the top-most parent. This works fine. I'd like to tap into the after_create callback of one of the children to populate a changelog table. One of the attributes I need to copy/push into the changelog table is the child's foreign_key to it's direct parent, but it doesn't exist at the time after_create fires!?! Without the after_create callback, I can look in the log and see that the child is being saved before it's parent (foreign key blank) then the parent is inserted... then the child is updated with the id from the parent. The child's after_create is firing at the right time, but it happens before Rails has had a chance to update the child with the foreign_key. Is there any way to force Rails to save such a linkage of models in a certain order? ie.parent, then child (parent foreign_key exists), then that child's child (again, foreign_key is accessible) etc. ?? If not, how would I have my routine fire after a record is created AND get the foreign_key? Seems a callback like this would be helpful: after_create_with_foreign_keys

    Read the article

  • Pass Extra Parameters to JavaScript Callback Function

    - by BRADINO
    Here is a simple example of a function that takes a callback function as a parameter. query.send(handleQueryResponse); function handleQueryResponse(response){      alert('Processing...'); } If you wanted to pass extra variables to the callback function, you can do it like this. var param1 = 'something'; var param2 ='something else'; query.send(function(response) { handleQueryResponse(response, param1, param2) }); function handleQueryResponse(response,param1,param2){      alert('Processing...');      alert(param1);      alert(param2); }

    Read the article

  • C# Find and Replace a section of a string with wildcard type search using RegEx (while retaining som

    - by fraXis
    Hello, I am trying to replace some text in a string with different text while retaining some of the text and I am having trouble doing it. My code is: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); /Replace M2 with M3 (this works fine) content = Regex.Replace(content, "M2", "M3"); I want to replace a string that contains this: Z0.1G0H1E1 and turn it into: G54G43Z.1H1M08 (Note the Z value and the H value contain the same numeric value before the text change) The trouble I am having is that when I replace the values, I need to retain the H value and the Z value from the first set of text. For example, Z0.5G0H5E1 I need to add the new text, but also add the H5 and Z0.5 back into the text such as: G54G43Z0.5H5M08 But the Z values and H values will be different every time, so I need to capture those values and reinsert them back into the string when add the new G54G43 values. Can someone please show me how to do this using Regex.Replace? Thanks so much, Shawn

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >