Search Results

Search found 37697 results on 1508 pages for 'append string'.

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

  • Filter string in C

    - by Paul Tarjan
    How can I filter a string in c? I want to remove anything that isn't [a-z0-9_]. int main(int argc, char ** argv) { char* name = argv[1]; // remove anything that isn't [a-z0-9_] printf("%s", name); }

    Read the article

  • String Parsing in C#

    - by Betamoo
    What is the most efficient way to parse a C# string in the form of "(params (abc 1.3)(sdc 2.0)....)" into a struct in the form struct Params { double abc,sdc....; } Thanks EDIT The structure always have the same parameters (number and names).. but the order is not granted..

    Read the article

  • finding and returning a string with a specified prefix

    - by tipu
    I am close but I am not sure what to do with the restuling match object. If I do p = re.search('[/@.* /]', str) I'll get any words that start with @ and end up with a space. This is what I want. However this returns a Match object that I dont' know what to do with. What's the most computationally efficient way of finding and returning a string which is prefixed with a @? For example, "Hi there @guy" After doing the proper calculations, I would be returned guy

    Read the article

  • Jquery append input for 2 different input-sections

    - by Email
    Hi i use the following simple jquery script to append input. Source http://muiomuio.com/web-design/add-remove-items-with-jquery <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Add and Remove - jQuery tutorial</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { var i = $('input').size() + 1; $('a.add').click(function() { $('<p><input type="text" value="input ' + i + '" name="input_field'+ i +'" /></p>').animate({ opacity: "show" }, "slow").appendTo('#inputs'); i++; }); $('a.remove').click(function() { if(i > 2) { $('input:last').animate({opacity:"hide"}, "slow").remove(); i--; } }); $('a.reset').click(function() { while(i > 2) { $('input:last').remove(); i--; } }); }); </script> </head> <body> <h1>Add / remove text fields from webform</h1> <a href="#" class="add"><img src="add.png" width="24" height="24" alt="add" title="add input" /></a> <a href="#" class="remove"><img src="remove.png" width="24" height="24" alt="remove input" /></a> <a href="#" class="reset"><img src="reset.png" width="24" height="24" alt="reset" /></a> <div id="inputs"> <p> <input type="text" value="input 1" name="input_field1"> </p> </div> </div> </body> </html> I know want to add more input fields so i add this html <div id="outputs"> <p> <input type="text" value="output 1" name="output_field1"> </p> how can i achieve that the var i = $('input').size() + 1; will be individually for every input section? EDITED: the full script is the following. copy and paste will get you a full clone of mine. Problem still exists <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Add and Remove - jQuery tutorial</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { var i = $('input').size() + 1; $('a.add').click(function() { $('<p><input type="text" value="input ' + i + '" name="input_field'+ i +'" /></p>').animate({ opacity: "show" }, "slow").appendTo('#inputs'); i++; }); $('a.remove').click(function() { if(i > 2) { $('input:last').animate({opacity:"hide"}, "slow").remove(); i--; } }); $('a.reset').click(function() { while(i > 2) { $('input:last').remove(); i--; } }); $('a.add_o').click(function() { $('<p><input type="text" value="output ' + i + '" name="input_field'+ i +'" /></p>').animate({ opacity: "show" }, "slow").appendTo('#outputs'); i++; }); $('a.remove_o').click(function() { if(i > 2) { $('input:last').animate({opacity:"hide"}, "slow").remove(); i--; } }); $('a.reset_o').click(function() { while(i > 2) { $('input:last').remove(); i--; } }); }); </script> <style rel="stylesheet" type="text/css"> h1 { font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;} .hide {visibility:hidden;} img {border:none;} input { width:500px; height:20px; padding:10px; background:#f7f7f7; border:1px solid #f0f0f0; color:#333; font-size:20px; text-align:center; line-height:120px; margin:0; -moz-border-radius:5px; -webkit-border-radius:5px; } #inputs { width:520px; padding:0px 20px; border:1px solid #f0f0f0; -moz-border-radius:20px; -webkit-border-radius:20px; } </style> </head> <body> <h1>Add / remove text fields from webform</h1> <a href="#" class="add"><img src="http://muiomuio.com/tutorials/jquery/add-remove/add.png" width="24" height="24" alt="add" title="add input" /></a> <a href="#" class="remove"><img src="http://muiomuio.com/tutorials/jquery/add-remove/remove.png" width="24" height="24" alt="remove input" /></a> <a href="#" class="reset"><img src="http://muiomuio.com/tutorials/jquery/add-remove/reset.png" width="24" height="24" alt="reset" /></a> <div id="inputs"> <p> <input type="text" value="input 1" name="input_field1"> </p> </div> <a href="#" class="add_o"><img src="http://muiomuio.com/tutorials/jquery/add-remove/add.png" width="24" height="24" alt="add" title="add input" /></a> <a href="#" class="remove_o"><img src="http://muiomuio.com/tutorials/jquery/add-remove/remove.png" width="24" height="24" alt="remove input" /></a> <a href="#" class="reset_o"><img src="http://muiomuio.com/tutorials/jquery/add-remove/reset.png" width="24" height="24" alt="reset" /></a> <div id="outputs"> <p> <input type="text" value="output 1" name="output_field1"> </p> </div> </body> </html>

    Read the article

  • Append/Add Child Div (jQuery) for Messaging System

    - by Lord Varlin
    So, I'm having difficulty trying to append/add a child div to the parent div, and thought someone out here may know the best way for me to go about this. I have attached my code (without PHP right now, just hard coding text and stuff). But here is what I am trying to do: When a message is posted, you hit the "Reply Button" and a new div will appear underneath containing the reply form. Right now, here are the issues I know about and can't get around: The DIV is a class, so when I use jQuery to try to target the DIV it targets everything since it's no unique. The Reply Button is also a class, so it's not unique. Here is a video of it in action: http://tinypic.com/r/2luxwnr/7 HTML <body> <div id="content-container"> <div id="message-viewer"> <div class="roar"> <div class="roaractionpanel"> <div id="msg-business2"></div> <div class="roartime"><p class="roartime-text">3:26PM</p></div> </div> <div class="roarcontent"> <button type="submit" class="btn-reply"></button> <h5>Test Post</h5><br> <h6>Lord Varlin</h6><br> <h2>Test post... let's see.</h2> </div> </div> <div class="newreply"> <div class="newreplycontent"> <h1>This is where the fields for a new reply will go.</h1> </div> </div> <div class="roar"> <div class="roaractionpanel"> <div id="msg-business2"></div> <div class="roartime"><p class="roartime-text">3:26PM</p></div> </div> <div class="roarcontent"> <button type="submit" class="btn-reply"></button> <h5>Testing another</h5><br> <h6>Lord Varlin</h6><br> <h2>Hmm dee dumm...</h2> </div> </div> <div class="roarreply"> <div class="roarreply-marker"> <p class="roarreplytime-text">June 26th @ 4:42AM</p> </div> <div class="roarreplycontent"> <h9>Testing a reply. Hmmmm.</h9><br> <h8>Lord Varlin</h8> </div> </div> <div class="newreply"> <div class="newreplycontent"> <h1>This is where the fields for a new reply will go.</h1> </div> </div> <div class="roar"> <div class="roaractionpanel"> <div id="msg-business2"></div> <div class="roartime"><p class="roartime- text">3:26PM</p></div> </div> <div class="roarcontent"> <button type="submit" class="btn-reply"></button> <h5>Testing another</h5><br> <h6>Lord Varlin</h6><br> <h2>jQuery, work with me please.</h2> </div> </div> <div class="roarreply"> <div class="roarreply-marker"> <p class="roarreplytime-text">June 26th @ 4:42AM</p> </div> <div class="roarreplycontent"> <h9>Testing a reply. Hmmmm.</h9><br> <h8>Lord Varlin</h8> </div> </div> <div class="roarreply"> <div class="roarreply-marker"> <p class="roarreplytime-text">June 26th @ 4:42AM</p> </div> <div class="roarreplycontent"> <h9>Testing a reply. Hmmmm.</h9><br> <h8>Lord Varlin</h8> </div> </div> <div class="newreply"> <div class="newreplycontent"> <h1>This is where the fields for a new reply will go.</h1> </div> </div> </div> </div> </body> JQUERY $(".btn-reply").click(function() { $(".newreply").toggleClass("show"); return false; }); So, I see the flaws, but I just can't wrap my head around how to pull this off! Any guidance would be awesome! :)

    Read the article

  • Split a long JSON string into lines in Ruby

    - by David J.
    First, the background: I'm writing a Ruby app that uses SendGrid to send mass emails. SendGrid uses a custom email header (in JSON format) to set recipients, values to substitute, etc. SendGrid's documentation recommends splitting up the header so that the lines are shorter than 1,000 bytes. My question, then, is this: given a long JSON string, how can I split it into lines < 1,000 so that lines are split at appropriate places (i.e., after a comma) rather than in the middle of a word? This is probably unnecessary, but here's an example of the sort of string I'd like to split: X-SMTPAPI: {"sub": {"pet": ["dog", "cat"]}, "to": ["[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]"]} Thanks in advance for any help you can provide!

    Read the article

  • String.IsNullOrWhiteSpace

    - by Scott Dorman
    An empty string is different than an unassigned string variable (which is null), and is a string containing no characters between the quotes (""). The .NET Framework provides String.Empty to represent an empty string, and there is no practical difference between ("") and String.Empty. One of the most common string comparisons to perform is to determine if a string variable is equal to an empty string. The fastest and simplest way to determine if a string is empty is to test if the Length property is equal to 0. However, since strings are reference types it is possible for a string variable to be null, which would result in a runtime error when you tried to access the Length property. Since testing to determine if a string is empty is such a common occurrence, the .NET Framework provides the static method String.IsNullOrEmpty method: public static bool IsNullOrEmpty(string value) { if (value != null) { return (value.Length == 0); }   return true; } It is also very common to determine if a string is empty and contains more than just whitespace characters. For example, String.IsNullOrEmpty("   ") would return false, since this string is actually made up of three whitespace characters. In some cases, this may be acceptable, but in many others it is not. TO help simplify testing this scenario, the .NET Framework 4 introduces the String.IsNullOrWhiteSpace method: public static bool IsNullOrWhiteSpace(string value) { if (value != null) { for (int i = 0; i < value.Length; i++) { if (!char.IsWhiteSpace(value[i])) { return false; } } } return true; }   Using either String.IsNullOrEmpty or String.IsNullOrWhiteSpace helps ensure correctness, readability, and consistency, so they should be used in all situations where you need to determine if a string is null, empty, or contains only whitespace characters. Technorati Tags: .NET,C# 4

    Read the article

  • String replacement problem.

    - by fastcodejava
    I want to provide some template for a code generator I am developing. A typical pattern for class is : public ${class_type} ${class_name} extends ${super_class} implements ${interfaces} { ${class_body} } Problem is if super_class is blank or interfaces. I replace extends ${super_class} with empty string. But I get extra spaces. So a class with no super_class and interfaces end up like : public class Foo { //see the extra spaces before {? ${class_body} } I know I can replace multiple spaces with single, but is there any better approach?

    Read the article

  • Transforming a string to a valid PDO_MYSQL DSN

    - by Alix Axel
    What is the most concise way to transform a string in the following format: mysql:[/[/]][user[:pass]@]host[:port]/db[/] Into a usuable PDO connection/instance (using the PDO_MYSQL DSN), some possible examples: $conn = new PDO('mysql:host=host;dbname=db'); $conn = new PDO('mysql:host=host;port=3307;dbname=db'); $conn = new PDO('mysql:host=host;port=3307;dbname=db', 'user'); $conn = new PDO('mysql:host=host;port=3307;dbname=db', 'user', 'pass'); I've been trying some regular expressions (preg_[match|split|replace]) but they either don't work or are too complex, my gut tells me this is not the way to go but nothing else comes to my mind. Any suggestions?

    Read the article

  • PHP String tokenizer not working correctly

    - by asdadas
    I have no clue why strtok decided to break on me. Here is my code. I am tokenizing a string by dollar symbol $. echo 'Tokenizing this by $: ',$aliases,PHP_EOL; if(strlen($aliases) > 0) { //aliases check $token = strtok($aliases, '$'); while($token != NULL) { echo 'Found a token: ',$token,PHP_EOL; if(!isGoodLookup($token)) { echo 'ERROR: Invalid alias found.',PHP_EOL; stop($db); } $goodAliasesList[] = $token; $token = strtok('$'); } if($token == NULL) echo 'Found null token, moving on',PHP_EOL; } And this is my output: Tokenizing this by $: getaways$aaa Found a token: getaways Found null token, moving on str tok is not supposed to do this!! where is my aaa token!!

    Read the article

  • Finding multiple values in a string Jquery / Javascript

    - by user257503
    I have a three strings of categories "SharePoint,Azure,IT"; "BizTalk,Finance"; "SharePoint,Finance"; I need to find a way to check if a string contains for example "SharePoint" and "IT", or "BizTalk" and "Finance". The tests are individual strings themselces. How would i loop through all the category strings (1 - 3) and only return the ones which have ALL instances of the souce. i have tried the following function doesExist(source, filterArray) { var substr = filterArray.split(" "); jQuery.each(substr, function() { var filterTest = this; if(source.indexOf(filterTest) != -1 ) { alert("true"); return true; }else { alert("false"); return false; } }); } with little success...the code above checks one at a time rather than both so the results returned are incorrect. Any help would be great. Thanks Chris UPDATE: here is a link to a work in progress version..http://www.invisiblewebdesign.co.uk/temp/filter/#

    Read the article

  • Search for string allowing for one mismatches in any location of the string, Python

    - by Vincent
    I am working with DNA sequences of length 25 (see examples below). I have a list of 230,000 and need to look for each sequence in the entire genome (toxoplasma gondii parasite) I am not sure how large the genome is but much more that 230,000 sequences. I need to look for each of my sequences of 25 characters example(AGCCTCCCATGATTGAACAGATCAT). The genome is formatted as a continuous string ie (CATGGGAGGCTTGCGGAGCCTGAGGGCGGAGCCTGAGGTGGGAGGCTTGCGGAGTGCGGAGCCTGAGCCTGAGGGCGGAGCCTGAGGTGGGAGGCTT.........) I don't care where or how many times it is found, just yes or no. This is simple I think, str.find(AGCCTCCCATGATTGAACAGATCAT) But I also what to find a close match defined as wrong(mismatched) at any location but only 1 location and record the location in the sequnce. I am not sure how do do this. The only thing I can think of is using a wildcard and performing the search with a wildcard in each position. ie search 25 times. For example AGCCTCCCATGATTGAACAGATCAT AGCCTCCCATGATAGAACAGATCAT close match with a miss-match at position 13 Speed is not a big issue I am only doing it 3 times. i hope but it would be nice it was fast. The are programs that do this find matches and partial matches but I am looking for a type of partial match that is not available with these applications. Here is a similar post for pearl but they are only comparing sequnces not searching a continuous string Related post

    Read the article

  • Use of FTP "append" command

    - by sahs
    I want to upload a file to a ftp server programmatically (C++). If the connection is lost while uploading a file, I wouldn't want to upload the file from scratch, but to upload only the part that I haven't sent. Does the APPE command fulfill my demand? What list of FTP commands should I use exactly? And how?

    Read the article

  • Append all logs to /var/log

    - by iCy
    Application scenario: I have the (normal/permanent) /var/log mounted on an encrypted partition (/dev/LVG/log). /dev/LVG/log is not accessible at boot time, it needs to be manually activated later by su from ssh. A RAM drive (using tmpfs) is mounted to /var/log at init time (in rc.local). Once /dev/LVG/log is activated, I need a good way of appending everything in the tmpfs to /dev/LVG/log, before mounting it as /var/log. Any recommendations on what would be a good way of doing so? Thanks in advance!

    Read the article

  • C# collection/string .Contains vs collection/string.IndexOf

    - by Daniel
    Is there a reason to use .Contains on a string/list instead of .IndexOf? Most code that I would write using .Contains would shortly after need the index of the item and therefore would have to do both statements. But why not both in one? if ((index = blah.IndexOf(something) = 0) // i know that Contains is true and i also have the index

    Read the article

  • Finding substring of a word found in joining a string from another string

    - by 2er0
    Given a list of words, L, that are all the same length, and a string, S, find the starting position of the substring of S that is a concatenation of each word in L exactly once and without any intervening characters. This substring will occur exactly once in S. Example: L: "fooo", "barr", "wing", "ding", "wing" S: "lingmindraboofooowingdingbarrwingmonkeypoundcake" Word found in joining L and also found in S: "fooowingdingbarrwing" Answer: 13 L: "mon", "key" S: "monkey Word found in joining L and also found in S: "monkey Answer: 0 L: "a", "b", "c", "d", "e" S: "abcdfecdba" Word found in joining L and also found in S: "ecdba Answer: 5

    Read the article

  • Remove characters after specific character in string, then remove substring?

    - by sah302
    I feel kind of dumb posting this when this seems kind of simple and there are tons of questions on strings/characters/regex, but I couldn't find quite what I needed (except in another language: http://stackoverflow.com/questions/2176544/remove-all-text-after-certain-point). I've got the following code: [Test] public void stringManipulation() { String filename = "testpage.aspx"; String currentFullUrl = "http://localhost:2000/somefolder/myrep/test.aspx?q=qvalue"; String fullUrlWithoutQueryString = currentFullUrl.Replace("?.*", ""); String urlWithoutPageName = fullUrlWithoutQueryString.Remove(fullUrlWithoutQueryString.Length - filename.Length); String expected = "http://localhost:2000/somefolder/myrep/"; String actual = urlWithoutPageName; Assert.AreEqual(expected, actual); } I tried the solution in the question above (hoping the syntax would be the same!) but nope. I want to first remove the queryString which could be any variable length, then remove the page name, which again could be any length. How can I get the remove the query string from the full URL such that this test passes?

    Read the article

  • How to extract specific variables from a string?

    - by David
    Hi, let's say i have the following: $vars="name=david&age=26&sport=soccer&birth=1984"; I want to turn this into real php variables but not everything. By example, the functions that i need : $thename=getvar($vars,"name"); $theage=getvar($vars,"age"); $newvars=cleanup($vars,"name,age"); // Output $vars="name=david&age=26" How can i get only the variables that i need . And how i clean up the $vars from the other variables if possible? Thanks

    Read the article

  • String formatting error

    - by wrongusername
    Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error: AttributeError: 'str' object has no attribute 'format' when I delete the line Netbeans automatically inserted at the beginning: from distutils.command.bdist_dumb import format which itself causes an error of ImportError: cannot import name format What am I doing wrong here?

    Read the article

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