Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 27/1413 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • JQuery removing '-' character from string

    - by Zaps
    Hi, I hope this question isn't too basic. I have a string "-123445". Is it possible to remove the '-' character from the string? I have tried the following but to no avail: $mylabel.text("-123456"); $mylabel.text().replace('-', ''); Any help would be greatly appreciated. Thanks, Zaps

    Read the article

  • In String.replace("\c","") what ASCII value is ""?

    - by Tom
    Hi, im just writing my own replace method for any weird characters and i used the ASCI value 0, null to replace unwanted characters, i was hoping for them to be 'deleted', but this doesnt work. A gap just appears in the string. What exactly does String.Replace() do when removing a character for ""? Does it shift them all down and then 'delete' the final character or something?

    Read the article

  • C character from string shortcut

    - by Jay
    In javascript I am used to just being able to pick any character from a string like "exm[2]" and it would return to me the third character in a string. In C is there a way to do that or something without a function that requires a buffer?

    Read the article

  • Why string.Replace("X","Y") works only when assigned to new string?

    - by Petr
    Hi, I guess it has to do something with string being a reference type but I dont get why simply string.Replace("X","Y") does not work? Why I need to do `string A=stringB.Replace("X","Y") I thought it is just a method to be done on specified instance? Thanks for explanation EDIT: Thank you so far. I extend my question Why "b+="FFF"works but the b.replace is not?

    Read the article

  • (PHP) - Changing two substrings inside a string

    - by Imp4ct
    This is my BIG string BEGIN:VEVENT UID:xxxxxx DTSTAMP:xxxxxx STATUS:CONFIRMED CLASS:PUBLIC URL:xxxxxx SUMMARY:YYYYYYY DESCRIPTION:xxxxxx; YYYYYYY; DTSTART:xxxxxx DTEND:xxxxxx GEO:xxxxxx LOCATION:xxxxxx END:VEVENT I need to change position of the two "YYYYYYY" in SUMMARY/DESCRIPTION I have to replace them without being specific since it is implemented in a much larger function. (This string is already sliced out of a 3700 line - Calendar) pls help! :)

    Read the article

  • Convert list of dicts to string

    - by John
    I'm very new to Python, so forgive me if this is easier than it seems to me. I'm being presented with a list of dicts as follows: [{'directMember': 'true', 'memberType': 'User', 'memberId': '[email protected]'}, {'directMember': 'true', 'memberType': 'User', 'memberId': '[email protected]'}, {'directMember': 'true', 'memberType': 'User', 'memberId': '[email protected]'}] I would like to generate a simple string of memberIds, such as [email protected], [email protected], [email protected] but every method of converting a list to a string that I have tried fails because dicts are involved. Any advice?

    Read the article

  • Compile time Meta-programming, with string literals.

    - by Hassan Syed
    I'm writing some code which could really do with some simple compile time metaprogramming. It is common practise to use empty-struct tags as compile time symbols. I need to decorate the tags with some run-time config elements. static variables seem the only way to go (to enable meta-programming), however static variables require global declarations. to side step this Scott Myers suggestion (from the third edition of Effective C++), about sequencing the initialization of static variables by declaring them inside a function instead of as class variables, came to mind. So I came up with the following code, my hypothesis is that it will let me have a compile-time symbols with string literals use-able at runtime. I'm not missing anything I hope. template<class Instance> class TheBestThing { public: void set_name(const char * name_in) { get_name() = std::string(name_in); } void set_fs_location(const char * fs_location_in) { get_fs_location() = std::string(fs_location_in); } std::string & get_fs_location() { static std::string fs_location; return fs_location; } std::string & get_name() { static std::string name; return name; } }; struct tag {}; int main() { TheBestThing<tag> x; x.set_name("xyz"); x.set_fs_location("/etc/lala"); ImportantObject<x> SinceSlicedBread; }

    Read the article

  • java: how to compress data into a String and uncompress data from the String

    - by Guillaume
    I want to put some compressed data into a remote repository. To put data on this repository I can only use a method that take the name of the resource and its content as a String. (like data.txt + "hello world"). The repository is moking a filesystem but is not, so I can not use File directly. I want to be able to do the following: client send to server a file 'data.txt' server compress 'data.txt' into data.zip server send to repository content of data.zip repository store data.zip client download from repository data.zip and his able to open it with its favorite zip tool I have tried a lots of compressing example found on the web but each time a send the data to the repository, my resulting zip file is corrupted. Here is a sample class, using the zip*stream and that emulate the repository showcasing my problem. The created zip file is working, but after its 'serialization' it's get corrupted. (the sample class use jakarta commons.io ) Many thanks for your help. package zip; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; import org.apache.commons.io.FileUtils; /** * Date: May 19, 2010 - 6:13:07 PM * * @author Guillaume AME. */ public class ZipMe { public static void addOrUpdate(File zipFile, File ... files) throws IOException { File tempFile = File.createTempFile(zipFile.getName(), null); // delete it, otherwise you cannot rename your existing zip to it. tempFile.delete(); boolean renameOk = zipFile.renameTo(tempFile); if (!renameOk) { throw new RuntimeException("could not rename the file " + zipFile.getAbsolutePath() + " to " + tempFile.getAbsolutePath()); } byte[] buf = new byte[1024]; ZipInputStream zin = new ZipInputStream(new FileInputStream(tempFile)); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile)); ZipEntry entry = zin.getNextEntry(); while (entry != null) { String name = entry.getName(); boolean notInFiles = true; for (File f : files) { if (f.getName().equals(name)) { notInFiles = false; break; } } if (notInFiles) { // Add ZIP entry to output stream. out.putNextEntry(new ZipEntry(name)); // Transfer bytes from the ZIP file to the output file int len; while ((len = zin.read(buf)) > 0) { out.write(buf, 0, len); } } entry = zin.getNextEntry(); } // Close the streams zin.close(); // Compress the files if (files != null) { for (File file : files) { InputStream in = new FileInputStream(file); // Add ZIP entry to output stream. out.putNextEntry(new ZipEntry(file.getName())); // Transfer bytes from the file to the ZIP file int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } // Complete the entry out.closeEntry(); in.close(); } // Complete the ZIP file } tempFile.delete(); out.close(); } public static void main(String[] args) throws IOException { final String zipArchivePath = "c:/temp/archive.zip"; final String tempFilePath = "c:/temp/data.txt"; final String resultZipFile = "c:/temp/resultingArchive.zip"; File zipArchive = new File(zipArchivePath); FileUtils.touch(zipArchive); File tempFile = new File(tempFilePath); FileUtils.writeStringToFile(tempFile, "hello world"); addOrUpdate(zipArchive, tempFile); //archive.zip exists and contains a compressed data.txt that can be read using winrar //now simulate writing of the zip into a in memory cache String archiveText = FileUtils.readFileToString(zipArchive); FileUtils.writeStringToFile(new File(resultZipFile), archiveText); //resultingArchive.zip exists, contains a compressed data.txt, but it can not //be read using winrar: CRC failed in data.txt. The file is corrupt } }

    Read the article

  • Gödel, Escher, Bach - Gödel's string

    - by Brad Urani
    In the book Gödel, Escher, Bach: An Eternal Golden Braid by Douglas Hofstadter, the author gives us a representation of the precursor to Gödel's string (Gödel's string's uncle) as: ~Ea,a': (I don't have the book in front of me but I think that's right). All that remains to get Gödel's string is to plug the Gödel number for this string into the free variable a''. What I don't understand is how to get the Gödel number for the functions PROOF-PAIR and ARITHMOQUINE. I understand how to write these functions in a programming language like FlooP (from the book) and could even write them myself in C# or Java, but the scheme that Hofstadter defines for Gödel numbering only applies to TNT (which is just his own syntax for natural number theory) and I don't see any way to write a procedure in TNT since it doesn't have any loops, variable assignments etc. Am I missing the point? Perhaps Gödel's string is not something that can actually be printed, but rather a theoretical string that need not actually be defined? I thought it would be neat to write a computer program that actually prints Gödel's string, or Gödel's string encoded by Gödel numbering (yes, I realize it would have a gazillion digits) but it seems like doing so requires some kind of procedural language and a Gödel numbering system for that procedural language that isn't included in the book. Of course once you had that, you could write a program that plugs random numbers into variable "a" and run procedure PROOF-PAIR on it to test for theoromhood of Gödel's string. If you let it run for a trillion years you might find a derivation that proves Gödel's string.

    Read the article

  • MSTest project can't get localized string?

    - by miliu
    I ran into a strange problem. In my unit test, I want to check the localized strings. However, I can't seem to get it work. For example, I created two resources: Resource1.resx for English and Resource1.zh-CN.resx for Chinese. The unit test project can only get the (default?) English resource string. This is the code I'm using: ResourceManager actual = new ResourceManager(typeof(LocaleTest.Properties.Resource1)); string name0 = actual.GetString("Name", new CultureInfo("en-US")); string name1 = actual.GetString("Name", new CultureInfo("zh-CN")); I created another regular project (means not a MSTest project) to make sure the localized strings are working. So, it works in a regular project, but not in a MSTest project. It didn't help even if I put the following code to make 'zh-CN' as the current culture of the unit test: [TestInitialize()] public void MyTestInitialize() { Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN"); } Anybody has seen similar problems? Is there any workaround?

    Read the article

  • LPCSTR, TCHAR, String

    - by user285327
    I am use next type of strings: LPCSTR, TCHAR, String i want to convert: 1) from TCHAR to LPCSTR 2) from String to char I convert from TCHAR to LPCSTR by that code: RunPath = TEXT("C:\\1"); LPCSTR Path = (LPCSTR)RunPath; From String to char i convert by that code: SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog; saveFileDialog1->Title = "?????????? ?????-????????"; saveFileDialog1->Filter = "bck files (*.bck)|*.bck"; saveFileDialog1->RestoreDirectory = true; pin_ptr<const wchar_t> wch = TEXT(""); if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { wch = PtrToStringChars(saveFileDialog1->FileName); } else return; ofstream os(wch, ios::binary); My problem is that when i set "Configuration Properties - General Character Set in "Use Multi-Byte Character Set" the first part of code work correctly. But the second part of code return error C2440. When i set "Configuration Properties - General Character Set in "Use Unicode" the second part of code work correctly. But the first part of code return the only first character from TCHAR to LPCSTR.

    Read the article

  • Speed vs security vs compatibility over methods to do string concatenation in Python

    - by Cawas
    Similar questions have been brought (good speed comparison there) on this same subject. Hopefully this question is different and updated to Python 2.6 and 3.0. So far I believe the faster and most compatible method (among different Python versions) is the plain simple + sign: text = "whatever" + " you " + SAY But I keep hearing and reading it's not secure and / or advisable. I'm not even sure how many methods are there to manipulate strings! I could count only about 4: There's interpolation and all its sub-options such as % and format and then there's the simple ones, join and +. Finally, the new approach to string formatting, which is with format, is certainly not good for backwards compatibility at same time making % not good for forward compatibility. But should it be used for every string manipulation, including every concatenation, whenever we restrict ourselves to 3.x only? Well, maybe this is more of a wiki than a question, but I do wish to have an answer on which is the proper usage of each string manipulation method. And which one could be generally used with each focus in mind (best all around for compatibility, for speed and for security). Thanks.

    Read the article

  • fgets in c doesn't return a portion of an string

    - by Marc
    Hi! I'm totally new in C, and I'm trying to do a little application that searches a string into a file, my problem is that I need to open a big file (more than 1GB) with just one line inside and fgets return me the entire file (I'm doing test with a 10KB file). actually this is my code: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char *search = argv[argc-1]; int retro = strlen(search); int pun = 0; int sortida; int limit = 10; char ara[20]; FILE *fp; if ((fp = fopen ("SEARCHFILE", "r")) == NULL){ sortida = -1; exit (1); } while(!feof(fp)){ if (fgets(ara, 20, fp) == NULL){ break; } //this must be a 20 bytes line, but it gets the entyre 10Kb file printf("%s",ara); } sortida = 1; if(fclose(fp) != 0){ sortida = -2; exit (1); } return 0; } What can I do to find an string into a file? I'v tried with GREP but it don't helps, because it returns the position:ENTIRE_STRING. I'm open to ideas. Thanks in advance!

    Read the article

  • speed string search in PHP

    - by Marc
    Hi! I have a 1.2GB file that contains a one line string. What I need is to search the entire file to find the position of an another string (currently I have a list of strings to search). The way what I'm doing it now is opening the big file and move a pointer throught 4Kb blocks, then moving the pointer X positions back in the file and get 4Kb more. My problem is that a bigger string to search, a bigger time he take to got it. Can you give me some ideas to optimize the script to get better search times? this is my implementation: function busca($inici){ $limit = 4096; $big_one = fopen('big_one.txt','r'); $options = fopen('options.txt','r'); while(!feof($options)){ $search = trim(fgets($options)); $retro = strlen($search);//maybe setting this position absolute? (like 12 or 15) $punter = 0; while(!feof($big_one)){ $ara = fgets($big_one,$limit); $pos = strpos($ara,$search); $ok_pos = $pos + $punter; if($pos !== false){ echo "$pos - $punter - $search : $ok_pos <br>"; break; } $punter += $limit - $retro; fseek($big_one,$punter); } fseek($big_one,0); } } Thanks in advance!

    Read the article

  • drupal: standard way for creating a slug from a string

    - by egarcia
    Hi there, A slug on this context is a string that its safe to use as an identifier, on urls or css. For example, if you have this string: I'd like to eat at McRunchies! Its slug would be: i-d-like-to-eat-at-mcrunchies- I want to know whether there's a standard way of building such strings on Drupal (or php functions available from drupal). More precisely, inside a Drupal theme. Context: I'm modifying a drupal theme so the html of the nodes it generates include their taxonomy terms as css classes on their containing div. Trouble is, some of those terms' names aren't valid css class names. I need to "slugify" the them. I've read that some people simply do this: str_replace(" ", "-", $term->name) This isn't really a enough for me. It doesn't replace uppercase letters with downcase, but more importantly, doesn't replace non-ascii characters (like à or é) by their ascii equivalents. Is there a function in drupal 6 (or the php libs) that provides a way to slugify a string, and can be used on a template.php file of a drupal theme?

    Read the article

  • fgets in c don't return a portion of an string

    - by Marc
    Hi! I'm totally new in C, and I'm trying to do a little application that searches a string into a file, my problem is that I need to open a big file (more than 1GB) with just one line inside and fgets return me the entire file (I'm doing test with a 10KB file). actually this is my code: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char *search = argv[argc-1]; int retro = strlen(search); int pun = 0; int sortida; int limit = 10; char ara[20]; FILE *fp; if ((fp = fopen ("SEARCHFILE", "r")) == NULL){ sortida = -1; exit (1); } while(!feof(fp)){ if (fgets(ara, 20, fp) == NULL){ break; } //this must be a 20 bytes line, but it gets the entyre 10Kb file printf("%s",ara); } sortida = 1; if(fclose(fp) != 0){ sortida = -2; exit (1); } return 0; } What can I do to find an string into a file? I'v tried with GREP but it don't helps, because it returns the position:ENTIRE_STRING. I'm open to ideas. Thanks in advance!

    Read the article

  • I am trying to find how many vowels and consonants in my string in C

    - by John Walter
    #include <stdio.h> #include <string.h> int main() { int i; int counter=0, counter2=0; char *s; char name[30]; char vowel[6] = "AEIOU"; char consonants[21] = "BCDFGHJKLMNPQRSTVWXYZ"; printf ("input the string: "); scanf ("%s", name); printf ("The string is %s\n", name); for (i=0; name[i]!='\0'; i++) { if (s = strchr(vowel, name[i])) { counter++; } else if (s =strchr(consonants, name[i])) { counter2++; } printf ("First counter is %d\n", counter); printf ("The second counter is %d\n", counter2); return 0; } } And the question is, what is wrong with my code? why counter is not working? Because I tried a lot of ways, and nothing works, maybe someone can explain for me.

    Read the article

  • Aligning music notes using String matching algorithms or Dynamic Programming

    - by Dolphin
    Hi I need to compare 2 sets of musical pieces (i.e. a playing-taken in MIDI format-note details extracted and saved in a database table, against sheet music-taken into XML format). When evaluating playing against sheet music (i.e.note details-pitch, duration, rhythm), note alignment needs to be done - to identify missed/extra/incorrect/swapped notes that from the reference (sheet music) notes. I have like 1800-2500 notes in one piece approx (can even be more-with polyphonic, right now I'm doing for monophonic). So will I have to have all these into an array? Will it be memory overloading or stack overflow? There are string matching algorithms like KMP, Boyce-Moore. But note alignment can also be done through Dynamic Programming. How can I use Dynamic Programming to approach this? What are the available algorithms? Is it about approximate string matching? Which approach is much productive? String matching algos like Boyce-Moore, or dynamic programming? How can I assess which is more effective? Greatly appreciate any insight or suggestions Thanks in advance

    Read the article

  • Convert a raw string to an array of big-endian words with Ruby

    - by Zag zag..
    Hello, I would like to convert a raw string to an array of big-endian words. As example, here is a JavaScript function that do it well (by Paul Johnston): /* * Convert a raw string to an array of big-endian words * Characters >255 have their high-byte silently ignored. */ function rstr2binb(input) { var output = Array(input.length >> 2); for(var i = 0; i < output.length; i++) output[i] = 0; for(var i = 0; i < input.length * 8; i += 8) output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32); return output; } I believe the Ruby equivalent can be String#unpack(format). However, I don't know what should be the correct format parameter. Thank you for any help. Regards

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >