Search Results

Search found 36172 results on 1447 pages for 'unicode string'.

Page 112/1447 | < Previous Page | 108 109 110 111 112 113 114 115 116 117 118 119  | Next Page >

  • Are pointers primitive types in C++?

    - by Space_C0wb0y
    I was wondering about the last constructor for std::string mentioned here. It says: template<class InputIterator> string (InputIterator begin, InputIterator end); If InputIterator is an integral type, behaves as the sixth constructor version (the one right above this) by typecasting begin and end to call it: string(static_cast<size_t>(begin),static_cast<char>(end)); In any other case, the parameters are taken as iterators, and the content is initialized with the values of the elements that go from the element referred by iterator begin to the element right before the one referred by iterator end. So what does that mean if InputIterator is a char * ?

    Read the article

  • C# enum to string auto-conversion?

    - by dcompiled
    Is it possible to have the compiler automatically convert my Enum values to strings so I can avoid explicitly calling the ToString method every time. Here's an example of what I'd like to do: enum Rank { A, B, C } Rank myRank = Rank.A; string myString = Rank.A; // Error: Cannot implicitly convert type 'Rank' to 'string' string myString2 = Rank.A.ToString(); // OK: but is extra work

    Read the article

  • Forced closed only when put alphabetical string in edit text

    - by Abdullah Al Mubarok
    So, I make a checker if an id is in the database or not, the id is in numerical string, the type in database is char(6) though. So this is my code public class input extends Activity{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.input); final EditText edittext = (EditText)findViewById(R.id.editText1); Button button = (Button)findViewById(R.id.button1); button.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub String nopel = edittext.getText().toString(); if(nopel.length() == 0){ Toast.makeText(getApplicationContext(), "error", Toast.LENGTH_SHORT).show(); }else{ List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("nopel", nopel)); JSON json_dp = new JSON(); JSONObject jobj_dp = json_dp.getJSON("http://10.0.2.2/KP/pdam/nopel.php", pairs); try { if(jobj_dp.getInt("row") == 0){ Toast.makeText(getApplicationContext(), "error", Toast.LENGTH_SHORT).show(); }else{ String snopel = jobj_dp.getString("nopel"); String snama = jobj_dp.getString("nama"); String salamat = jobj_dp.getString("alamat"); String sgolongan = jobj_dp.getString("golongan"); Intent i = new Intent(input.this, list.class); i.putExtra("nopel", snopel); i.putExtra("nama", snama); i.putExtra("alamat", salamat); i.putExtra("golongan", sgolongan); startActivity(i); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); } } the first check is to check if an input is null, it's going right for now, the second check is to check if an id in the database, and it's the problem. When I try some id in numerical value like "0001" or "02013" it's fine, and can run. but when I just got to put "abushd" it forced close. anyone know why I got this?

    Read the article

  • Is there a way to define a List<> of two elements string array?

    - by Alexander Prokofyev
    I want to build two-dimentional array of strings where length of one dimention is 2. Similar to this string[,] array = new string[,] { {"a", "b"}, {"c", "d"}, {"e", "f"}, {"g", "h"} } Doing List<string[]> list = new List<string[]>(); list.Add(new string[2] {"a", "b"}); list.Add(new string[2] {"c", "d"}); list.Add(new string[2] {"e", "f"}); list.Add(new string[2] {"g", "h"}); list.ToArray(); gives me string[][] but not string[,] array. Just curious, is there some trick to build dynamically string[,] array somehow?

    Read the article

  • Why, in Ruby, does Array("foo\nbar") == ["foo\n", "bar"]?

    - by Tyson
    In Ruby 1.8.7, Array("hello\nhello") gives you ["hello\n", "hello"]. This does two things that I don't expect: It splits the string on newlines. I'd expect it simply to give me an array with the string I pass in as its single element without modifying the data I pass in. Even if you accept that it's reasonable to split a string when passing it to Array, why does it retain the newline character when "foo\nbar".split does not? Additionally: >> Array.[] "foo\nbar" => ["foo\nbar"] >> Array.[] *"foo\nbar" => ["foo\n", "bar"]

    Read the article

  • Python Speeding Up Retrieving data from extremely large string

    - by Burninghelix123
    I have a list I converted to a very very long string as I am trying to edit it, as you can gather it's called tempString. It works as of now it just takes way to long to operate, probably because it is several different regex subs. They are as follow: tempString = ','.join(str(n) for n in coords) tempString = re.sub(',{2,6}', '_', tempString) tempString = re.sub("[^0-9\-\.\_]", ",", tempString) tempString = re.sub(',+', ',', tempString) clean1 = re.findall(('[-+]?[0-9]*\.?[0-9]+,[-+]?[0-9]*\.?[0-9]+,' '[-+]?[0-9]*\.?[0-9]+'), tempString) tempString = '_'.join(str(n) for n in clean1) tempString = re.sub(',', ' ', tempString) Basically it's a long string containing commas and about 1-5 million sets of 4 floats/ints (mixture of both possible),: -5.65500020981,6.88999986649,-0.454999923706,1,,,-5.65500020981,6.95499992371,-0.454999923706,1,,, The 4th number in each set I don't need/want, i'm essentially just trying to split the string into a list with 3 floats in each separated by a space. The above code works flawlessly but as you can imagine is quite time consuming on large strings. I have done a lot of research on here for a solution but they all seem geared towards words, i.e. swapping out one word for another. EDIT: Ok so this is the solution i'm currently using: def getValues(s): output = [] while s: # get the three values you want, discard the 3 commas, and the # remainder of the string v1, v2, v3, _, _, _, s = s.split(',', 6) output.append("%s %s %s" % (v1.strip(), v2.strip(), v3.strip())) return output coords = getValues(tempString) Anyone have any advice to speed this up even farther? After running some tests It still takes much longer than i'm hoping for. I've been glancing at numPy, but I honestly have absolutely no idea how to the above with it, I understand that after the above has been done and the values are cleaned up i could use them more efficiently with numPy, but not sure how NumPy could apply to the above. The above to clean through 50k sets takes around 20 minutes, I cant imagine how long it would be on my full string of 1 million sets. I'ts just surprising that the program that originally exported the data took only around 30 secs for the 1 million sets

    Read the article

  • String Compression using Lempel-Ziv

    - by roybot
    Im looking for a way of compressing a given string using the Lempel-Ziv Algorithm. Preferably there would only be a set of two functions, encoder and decoder. The encoder takes the string and returns an integer. The decoder takes the integer and returns the original string. Time complexity is not important. How would you implement this?

    Read the article

  • how to copy char * into a string and vice-versa

    - by user295030
    If i pass a char * into a function. I want to then take that char * convert it to a std::string and once I get my result convert it back to char * from a std::string to show the result. I don't know how to do this for conversion ( I am not talking const char * but just char *) I am not sure how to manipulate the value of the pointer I send in. so steps i need to do take in a char * convert it into a string. take the result of that string and put it back in the form of a char * return the result such that the value should be available outside the function and not get destroyed. If possible can i see how it could be done via reference vs a pointer (whose address I pass in by value however I can still modify the value that pointer is pointing to. so even though the copy of the pointer address in the function gets destroyed i still see the changed value outside. thanks!

    Read the article

  • More elegant way to parse inline variables in strings

    - by Tom
    Currently I have this: function parse_string($string, $variables){ extract($variables); return eval('return "'. addcslashes($string, '"') .'";'); } So I can input this string: 'Hi {$name}, my name is {$own_name}' Together with this array: array('name' => 'John', 'own_name' => 'Tom') And get this back: 'Hi John, my name is Tom'   I've never liked this eval() approach but it works and it's fast (faster than regex at least). Question: Is there a more elegant way to do this (faster than using regex) in PHP5?

    Read the article

  • Python elegant inverse function of int(string,base)

    - by random guy
    python allows conversions from string to integer using any base in the range [2,36] using: int(string,base) im looking for an elegant inverse function that takes an integer and a base and returns a string for example >>> str_base(224,15) 'ee' i have the following solution: def digit_to_char(digit): if digit < 10: return chr(ord('0') + digit) else: return chr(ord('a') + digit - 10) def str_base(number,base): if number < 0: return '-' + str_base(-number,base) else: (d,m) = divmod(number,base) if d: return str_base(d,base) + digit_to_char(m) else: return digit_to_char(m) note: digit_to_char() works for bases <= 169 arbitrarily using ascii characters after 'z' as digits for bases above 36 is there a python builtin, library function, or a more elegant inverse function of int(string,base) ?

    Read the article

  • Format the output of a string

    - by prince23
    hi here string strScore="2"; or string strScore="2.45656" now here i am checking the condition if it is double value = double.Parse(strScore); strScore = value.ToString("##.##"); 2.45656 like this then i am showing the output as 2.45 if the input is string strScore="2"; then the ouput is shown as "2" but now i need to show the output has 2.00 how can i format the code like this based on the condition

    Read the article

  • How to split this string in c#?

    - by melaos
    hi i'm really not used to the split string method in c# and i was wondering how come there's no split by more than one char function? and my attempt to try to split this string below using regex has just ended up in frustration. anybody can help me? basically i want to split the string below down to aa**aa**bb**dd^__^a2a**a2a**b2b**dd^__^ into aa**aa**bb**dd a2a**a2a**b2b**dd and then later into aa aa bb dd a2a a2a b2b dd thanks!

    Read the article

  • insert text in the middle of string in flex 3

    - by m6azeez
    hello all, can you please help me with this issue the String class does not have insert method it has only replace :( . what I need is: - if I have string "I stackoverflow" - I need to insert "love " at index 2 to have "I love stackoverflow" so what I need is insertAt(index, String) thanks

    Read the article

  • Filtering python string through external program

    - by Peter
    What's the cleanest way of filtering a Python string through an external program? In particular, how do you write the following function? def filter_through(s, ext_cmd): # Filters string s through ext_cmd, and returns the result. # Example usage: # filter a multiline string through tac to reverse the order. filter_through("one\ntwo\nthree\n", "tac") # => returns "three\ntwo\none\n" Note: the example is only that - I realize there are much better ways of reversing lines in python.

    Read the article

  • How do I not include part of a regular expression

    - by Axilus
    I'm pretty new to using regexes and I can figure out how I would go about extracted a specific number from a string. Suppose the string was any amount of whitespace or random text and somewhere within it is this, "Value: $1000.00." In order to retrieve that value I am currently using this: string value = Convert.ToString(Regex.Match(BodyContent, @"Value:[ \t]*\$?\d*(\.[0-9]{2})?", RegexOptions.Singleline)); So the variable 'value' now has, "Value: $1000.00" stored in it. My question is, using Regex is there a way to use 'Value:' to find the number value but only store the actual number value (i.e. 1000.00) in the 'value' variable?

    Read the article

  • String date time format

    - by Phil
    Hi i am using the vimeo API and i want to convert the string to a short date formate {0:d} or {0:dd/mm/yyyy}. This is my code but doesnt seem to be working for me. select new VimeoVideo { Date = String.Format("{0:d}",(item.Element("upload_date").Value)), }; return Vids.ToList(); } public class VimeoVideo { public string Date { get; set; } } Any help would be much appreciated Thanks

    Read the article

  • Retain Delimiters when Splitting String

    - by JoeC
    Edit: OK, I can't read, thanks to Col. Shrapnel for the help. If anyone comes here looking for the same thing to be answered... print_r(preg_split('/([\!|\?|\.|\!\?])/', $string, null, PREG_SPLIT_DELIM_CAPTURE)); Is there any way to split a string on a set of delimiters, and retain the position and character(s) of the delimiter after the split? For example, using delimiters of ! ? . !? turning this: $string = 'Hello. A question? How strange! Maybe even surreal!? Who knows.'; into this array('Hello', '.', 'A question', '?', 'How strange', '!', 'Maybe even surreal', '!?', 'Who knows', '.'); Currently I'm trying to use print_r(preg_split('/([\!|\?|\.|\!\?])/', $string)); to capture the delimiters as a subpattern, but I'm not having much luck.

    Read the article

  • Convert string from getline into a number

    - by haskellguy
    I am trying to create a 2D array with vectors. I have a file that has for each line a set of numbers. So what I did I implemented a split function that every time I have a new number (separated by \t) it splits that and add it to the vector vector<double> &split(const string &s, char delim, vector<double> &elems) { stringstream ss(s); string item; while (getline(ss, item, delim)) { cout << item << endl; double number = atof(item.c_str()); cout << number; elems.push_back(number); } return elems; } vector<double> split(const string &s, char delim) { vector<double> elems; split(s, delim, elems); return elems; } After that I simply iterate through it. int main() { ifstream file("./data/file.txt"); string row; vector< vector<double> > matrix; int line_count = -1; while (getline(file, row)) { line_count++; if (line_count <= 4) continue; vector<double> cols = split(row, '\t'); matrix.push_back(cols); } ... } Now my issues is in this bit here: while (getline(ss, item, delim)) { cout << item << endl; double number = atof(item.c_str()); cout << number; Where item.c_str() is converted to a 0. Shouldn't that be still a string having the same value as item? It works on a separate example if I do straight from string to c_string, but when I use this getline I end up in this error situation, hints?

    Read the article

  • Python: replace urls with title names from a string

    - by Hellnar
    Hello I would like to remove urls from a string replace them with their titles of the original contents. For example: mystring = "Ah I like this site: http://www.stackoverflow.com. Also I must say I like http://www.digg.com" sanitize(mystring) # it becomes "Ah I like this site: Stack Overflow. Also I must say I like Digg - The Latest News Headlines, Videos and Images" For replacing url to the title, I have written this snipplet: #get_title: string -> string def get_title(url): """Returns the title of the input URL""" output = BeautifulSoup.BeautifulSoup(urllib.urlopen(url)) return output.title.string

    Read the article

  • ruby parametrized regular expression

    - by astropanic
    I have a string like "{some|words|are|here}" or "{another|set|of|words}" So in general the string consists of an opening curly bracket,words delimited by a pipe and a closing curly bracket. What is the most efficient way to get the selected word of that string ? I would like do something like this: @my_string = "{this|is|a|test|case}" @my_string.get_column(0) # => "this" @my_string.get_column(2) # => "is" @my_string.get_column(4) # => "case" What should the method get_column contain ?

    Read the article

  • Scala : cleanest way to recursively parse files checking for multiple strings

    - by fred basset
    Hi All, I want to write a Scala script to recursively process all files in a directory. For each file I'd like to see if there are any cases where a string occurs at line X and line X - 2. If a case like that occurs I'd like to stop processing that file, and add that filename to a map of filenames to occurrence counts. I just started learning Scala today, I've got the file recurse code working, and need some help with the string searching, here's what I have so far: import java.io.File import scala.io.Source val s1= "CmdNum = 506" val s2 = "Data = [0000,]" def processFile(f: File) { val lines = scala.io.Source.fromFile(f).getLines.toArray for (i = 0 to lines.length - 1) { // want to do string searches here, see if line contains s1 and line two lines above also contains s1 //println(lines(i)) } } def recursiveListFiles(f: File): Array[File] = { val these = f.listFiles if (these != null) { for (i = 0 to these.length - 1) { if (these(i).isFile) { processFile(these(i)) } } these ++ these.filter(_.isDirectory).flatMap(recursiveListFiles) } else { Array[File]() } } println(recursiveListFiles(new File(args(0))))

    Read the article

< Previous Page | 108 109 110 111 112 113 114 115 116 117 118 119  | Next Page >