Search Results

Search found 1545 results on 62 pages for 'manipulation'.

Page 35/62 | < Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >

  • Java split is eating my characters.

    - by Fenris_uy
    Hi, I have a string like this String str = "la$le\$li$lo". I want to split it to get the following output "la","le\$li","lo". The \$ is a $ escaped so it should be left in the output. But when I do str.split("[^\\\\]\\$") y get "l","le\$l","lo". From what I get my regex is matching a$ and i$ and removing then. Any idea of how to get my characters back? Thanks

    Read the article

  • C++ stringstream reads all zero's

    - by user69514
    I have a file which contains three integers per line. When I read the line I use a stringstream to separate the values, but it only reads the first value as it is. The other two are read as zero's. ifstream inputstream(filename.c_str()); if( inputstream.is_open() ){ string line; stringstream ss; while( getline(inputstream, line) ){ //check line and extract elements int id; double income; int members; ss.clear(); ss.str(line); ss >> id >> income >> members; In the case above, id is extracted correctly, but income, and members get assigned zero instead of the actual value.

    Read the article

  • split a string into a key => value array in php

    - by andy-score
    +2-1+18*+7-21+3*-4-5+6x29 The above string is an example of the kind of string I'm trying to split into either a key = value array or something similar. The numbers represent the id of a class and -,+ and x represent the state of the class (minimised, expanded or hidden), the * represents a column break. I can split this into the columns easily using explode which gives and array with 3 $key = $value associations. eg. $column_layout = array( [0] => '+2-1+18' , [1] => '+7-21+3' , [2] => '-4-5+6x29' ) I then need to split this into the various classes from there, keeping the status and id together. eg. $column1 = array( '+' => 2 , '-' => 1 , '+' => 18 ) ... or $column1 = array( array( '+' , 2 ) , array( '-' , 1 ) , array( '+' , 18 ) ) ... I can't quite get my head round this and what the best way to do it is, so any help would be much appreciated.

    Read the article

  • Javascript: How to escape Unicode Chars

    - by user293006
    JSON String: { "id":31896, "name":"Zickey attitude - McKinley, La Rosi\u00e8re, 21 ao\u00fbt 2006", ... } this causes an unterminated string in javascript. my focus on solution is: data.replace(/(\S)\1(\1)+/g, ''); or data.replace(/\u([0-9A-Z])/, ''); any ideas/solution? example: http://api.jamendo.com/get2/id+name+url+stream+album_name+album_url+album_id+artist_id+artist_name/track/jsonpretty/track_album+album_artist/?n=13&order=ratingmonth_desc&tag_idstr=jazz last node is the problem, fyi. (/\u([0-9A-Z])/, '\1');

    Read the article

  • php string to array and split

    - by RussP
    Hi folks Looking for suggestions as to the best way to do this (I know there are many options): take a variable like this: $args = ('post_type=post&order_by=DESC&limit=10'); the create a function to convert that variable into parts like this: $post_type = post; $order_by = DESC; $limit= 10; Reason is I want a client to be able to use a string like the first to pass variables to a sql query in much the same way (but doesn't have to be exact) as you can do it in WordPress.

    Read the article

  • Manipulate method functionality call

    - by danrichardson
    Hello, is it possibly in c# to have some sort of base class functionality which is manipulated slightly based on the class. For instance say i have the following code (which will quite obviously not compile it's meant to only be for demonstrative purposes) class BaseFunctionality { public virtual bool adminCall public static string MethodName(int id, string parameter) { if (adminCall) return dbcall.Execute(); else return dbcall.ExecuteMe(); } } class Admin : BaseFunctionality { override bool adminCall = true; } class Front : BaseFunctionality { override bool adminCall = false; } Now what i would like to be able to do is; string AdminCall = Admin.MethodName(1, "foo"); string FrontCall = Front.MethodName(2, "bar"); Is their any way to do something like this? I'm trying to do everything with static methods so i do not have to instantiate classes all the time, and have nice clean code which is only being manipulated in one place. The idea behind this is so that there is minimal code repeating and makes things easier to expand on, so for instance another class could implement the BaseFunctionality later on. Thanks Dan

    Read the article

  • Fastest method to define whether a number is a triangular number

    - by psihodelia
    A triangular number is the sum of the n natural numbers from 1 to n. What is the fastest method to find whether a given positive integer number is a triangular one? I suppose, there must be a hidden pattern in a binary representation of such numbers (like if you need to find whether a number is even/odd you check its least significant bit). Here is a cut of the first 1200th up to 1300th triangular numbers, you can easily see a bit-pattern here (if not, try to zoom out): (720600, '10101111111011011000') (721801, '10110000001110001001') (723003, '10110000100000111011') (724206, '10110000110011101110') (725410, '10110001000110100010') (726615, '10110001011001010111') (727821, '10110001101100001101') (729028, '10110001111111000100') (730236, '10110010010001111100') (731445, '10110010100100110101') (732655, '10110010110111101111') (733866, '10110011001010101010') (735078, '10110011011101100110') (736291, '10110011110000100011') (737505, '10110100000011100001') (738720, '10110100010110100000') (739936, '10110100101001100000') (741153, '10110100111100100001') (742371, '10110101001111100011') (743590, '10110101100010100110') (744810, '10110101110101101010') (746031, '10110110001000101111') (747253, '10110110011011110101') (748476, '10110110101110111100') (749700, '10110111000010000100') (750925, '10110111010101001101') (752151, '10110111101000010111') (753378, '10110111111011100010') (754606, '10111000001110101110') (755835, '10111000100001111011') (757065, '10111000110101001001') (758296, '10111001001000011000') (759528, '10111001011011101000') (760761, '10111001101110111001') (761995, '10111010000010001011') (763230, '10111010010101011110') (764466, '10111010101000110010') (765703, '10111010111100000111') (766941, '10111011001111011101') (768180, '10111011100010110100') (769420, '10111011110110001100') (770661, '10111100001001100101') (771903, '10111100011100111111') (773146, '10111100110000011010') (774390, '10111101000011110110') (775635, '10111101010111010011') (776881, '10111101101010110001') (778128, '10111101111110010000') (779376, '10111110010001110000') (780625, '10111110100101010001') (781875, '10111110111000110011') (783126, '10111111001100010110') (784378, '10111111011111111010') (785631, '10111111110011011111') (786885, '11000000000111000101') (788140, '11000000011010101100') (789396, '11000000101110010100') (790653, '11000001000001111101') (791911, '11000001010101100111') (793170, '11000001101001010010') (794430, '11000001111100111110') (795691, '11000010010000101011') (796953, '11000010100100011001') (798216, '11000010111000001000') (799480, '11000011001011111000') (800745, '11000011011111101001') (802011, '11000011110011011011') (803278, '11000100000111001110') (804546, '11000100011011000010') (805815, '11000100101110110111') (807085, '11000101000010101101') (808356, '11000101010110100100') (809628, '11000101101010011100') (810901, '11000101111110010101') (812175, '11000110010010001111') (813450, '11000110100110001010') (814726, '11000110111010000110') (816003, '11000111001110000011') (817281, '11000111100010000001') (818560, '11000111110110000000') (819840, '11001000001010000000') (821121, '11001000011110000001') (822403, '11001000110010000011') (823686, '11001001000110000110') (824970, '11001001011010001010') (826255, '11001001101110001111') (827541, '11001010000010010101') (828828, '11001010010110011100') (830116, '11001010101010100100') (831405, '11001010111110101101') (832695, '11001011010010110111') (833986, '11001011100111000010') (835278, '11001011111011001110') (836571, '11001100001111011011') (837865, '11001100100011101001') (839160, '11001100110111111000') (840456, '11001101001100001000') (841753, '11001101100000011001') (843051, '11001101110100101011') (844350, '11001110001000111110') For example, can you also see a rotated normal distribution curve, represented by zeros between 807085 and 831405?

    Read the article

  • string update in sqlserver

    - by Thiyaneshwaran S
    Currently i have varchar field. The delimiter is "$P$P$". The delimiter will appear atleast once and atmost twice in the varchar data. Eg. Sample Heading$P$P$Sample description$P$P$Sample conclusion Sample Heading$P$P$Sample Description If the delimiter appears twice, i need to insert a text before the second occurance of the delimiter. Eg: Sample Heading$P$P$Sample DescriptionINSERT TEXT HERE$P$P$Sample Conclusion If the delimiter occurs only once, then i need to insert a text at the end of the field. Eg: Sample Heading$P$P$Sample DescriptionAPPEND TEXT HERE How this can be done in sql query?

    Read the article

  • C#: Loop through substring patterns in a string

    - by ilann
    my pattern is the following: {(code)} where code is a number (up to 6 digits), or 2 letter followed by a number. For example: {(45367)} {(265367)} {(EF127012)} I want to find all occurrences in a long string, I can't just use pure regex , because I need to preform some action when i find a match (like logging the position and the type of the match).

    Read the article

  • How does the stream manipulators work?

    - by Narek
    It is well known that the user can define stream manipulators like this: ostream& tab(ostream & output) { return output<< '\t'; } And this can be used in main() like this: cout<<'a'<<tab<<'b'<<'c'<<endl; Please explain me how does this all work? If operator<< assumes as a second parameter a pointer to the function that takes and returns ostream &, then please explain my why it is necessary? What would be wrong if the function does not take and return ostream & but it was void instead of ostream &? Also it is interesting why “dec”, “hex” manipulators take effect until I don’t change between them, but user defined manipulators should be always used in order to take effect for each streaming?

    Read the article

  • How do I unpack bits from a structure's stream_data in c code?

    - by Chelp
    Ex. typedef struct { bool streamValid; dword dateTime; dword timeStamp; stream_data[800]; } RadioDataA; Ex. Where stream_data[800] contains: **Variable** **Length (in bits)** packetID 8 packetL 8 versionMajor 4 versionMinor 4 radioID 8 etc.. I need to write: void unpackData(radioDataA *streamData, MA_DataA *maData) { //unpack streamData (from above) & put some of the data into maData //How do I read in bits of data? I know it's by groups of 8 but I don't understand how. //MAData is also a struct. }

    Read the article

  • Remove specified text from beginning of lines only if present (C#)

    - by Zach
    I have a textbox in which the user can edit text, in a scripting language. I've figured out how to let the user comment out lines in one click, but can't seem to figure out how to uncomment properly. For example, if the box has: Normal Text is here More normal text -- Commented text -- More commented text Normal Text again --Commented Text Again So, when the user selects any amount of text and decides to uncomment, the "--" is removed from the beginning of the lines that have it. The lines without the "--" should be unaffected. In short, I want an uncomment function that performs similar to the one in Visual Studio. Is there any way to accomplish this? Thanks

    Read the article

  • Efficient mapping for a particular finite integer set

    - by R..
    I'm looking for a small, fast (in both directions) bijective mapping between the following list of integers and a subset of the range 0-127: 0x200C, 0x200D, 0x200E, 0x200F, 0x2013, 0x2014, 0x2015, 0x2017, 0x2018, 0x2019, 0x201A, 0x201C, 0x201D, 0x201E, 0x2020, 0x2021, 0x2022, 0x2026, 0x2030, 0x2039, 0x203A, 0x20AA, 0x20AB, 0x20AC, 0x20AF, 0x2116, 0x2122 One obvious solution is: y = x>>2 & 0x40 | x & 0x3f; x = 0x2000 | y<<2 & 0x100 | y & 0x3f; Edit: I was missing some of the values, particularly 0x20Ax, which don't work with the above. Another obvious solution is a lookup table, but without making it unnecessarily large, a lookup table would require some bit rearrangement anyway and I suspect the whole task can be better accomplished with simple bit rearrangement. For the curious, those magic numbers are the only "large" Unicode codepoints that appear in legacy ISO-8859 and Windows codepages.

    Read the article

  • Strings - Filling In Leading Zeros Wtih A Zero

    - by headscratch
    I'm reading an array of hard-coded strings of numeric characters - all positions are filled with a character, even for the leading zeros. Thus, can confidently parse it using substring(start, end) to convert to numeric. Example: "0123 0456 0789" However, a string coming from a database does not fill in the leading zero with a 'zero character', it simply fetches the '123 456 789', which is correct for an arithmetic number but not for my needs and makes for parsing trouble. Before writing conditionals to check for leading zeros and adding them to the string if needed, is there a simple way of specifying they be filled with a character ? I'm not finding this in my Java book... I could have done the three conditionals in the time it took to post this but, this is more about 'education'... Thanks

    Read the article

  • Format String become xxx1, xx10 or 1****, 10*** etc

    - by trycatch4j
    Hi all, I have following numbers : 1, 2, 3, 4, 10 But I want to print those numbers like this: 0001 0002 0003 0004 0010 I have searched in Google. the keyword is number format. But I've got nothing, I just get, format decimal such ass 1,000,000.00. I hope you can suggest me a reference or give me something to solve this problem. Thanks Edit, we can use NumberFormat, or String.format("%4d", somevalue); but it just for adding 0 character before integer. How If I wanna use character such as x, # or maybe whitespace. So the character become: xxxx1 xxx10 or ####1 ###10 or 1#### 10###

    Read the article

  • How could I insert a string into the response stream anywhere I want?

    - by DM
    There may be an easy way to do this but I can't see it... I created a simple Http Module that starts a timer on the PreRequestHandler and stops the timer on the PostRequestHandler to calculate the time it took the page to load. I then create some simple html and write my results to Response.Write. Since I'm doing this in the PostRequestHandler it's adding my results after the </html> tag. That's fine for testing but I need in a scenario where the page needs to validate. I can't seem to figure out how I could manipulate the Response object to insert my results before the </body> tag. Response.Write and Response.Output.Write don't have that flexibility and I couldn't see a way to work with the Response as a string. Am I missing something easy?

    Read the article

  • whats wrong with strcpy()

    - by blacktooth
    What is wrong with strcpy() in this code? void process_filedata(char *filename) { void* content; const char * buffer; char * temp; char * row; char * col; int lsize,buflen,tmp,num_scan; //num_scan - number of characters scanned int m=0,p=0,d=0,j=0; //m - machine, p - phase, d- delimiter, j - job FILE *file_pointer = fopen("machinetimesnew.csv","r"); if(file_pointer == NULL) { error_flag = print_error("Error opening file"); if(error_flag) exit(1); } fseek(file_pointer, 0 ,SEEK_END); lsize = ftell(file_pointer); buflen = lsize; rewind(file_pointer); // content = (char*) malloc(sizeof(char)*lsize); fread(content,1,lsize,file_pointer); buffer = (const char*) content; strcpy(temp,buffer); row = strtok(temp,"\n"); ............... ............... I am getting a segmentation fault..

    Read the article

  • binary number comparison

    - by EquinoX
    If I have a 32 bit two's complement number and I want to know what is the easiest way to know of two numbers are equal... what would be the fastest bitwise operator to know this? I know xor'ing both numbers and check if the results are zero works well... any other one's? how about if a number is greater than 0?? I can check the 31'st bit to see if it's greater or equal to 0..but how about bgtz?

    Read the article

  • Getting the fractional part of a float without using modf()

    - by knight666
    Hi, I'm developing for a platform without a math library, so I need to build my own tools. My current way of getting the fraction is to convert the float to fixed point (multiply with (float)0xFFFF, cast to int), get only the lower part (mask with 0xFFFF) and convert it back to a float again. However, the imprecision is killing me. I'm using my Frac() and InvFrac() functions to draw an anti-aliased line. Using modf I get a perfectly smooth line. With my own method pixels start jumping around due to precision loss. This is my code: const float fp_amount = (float)(0xFFFF); const float fp_amount_inv = 1.f / fp_amount; inline float Frac(float a_X) { return ((int)(a_X * fp_amount) & 0xFFFF) * fp_amount_inv; } inline float Frac(float a_X) { return (0xFFFF - (int)(a_X * fp_amount) & 0xFFFF) * fp_amount_inv; } Thanks in advance!

    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

  • How does one find a '.' in a string object in Object-C

    - by NaZer
    I am working on getting a simple calculator working as part of my adventure to learning Object-C and iOS development. In Object-C using NSString, how does one look for a period in a string? Based on the comments this is what I got so far. NSString * tmp = [display text]; NSLog(@"%@", tmp); // Shows the number on the display correctly int x = [tmp rangeOfString:@"."].location; NSLog(@"%i", x); // Shows some random signed number if (x < 0) { [display setText:[[display text] stringByAppendingFormat:@"."]]; } It is still not working :(

    Read the article

< Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >