Search Results

Search found 37183 results on 1488 pages for 'string conversion'.

Page 101/1488 | < Previous Page | 97 98 99 100 101 102 103 104 105 106 107 108  | Next Page >

  • Iptables string

    - by Mr. BeatMasta
    I have an iptables rule like this: iptables -t nat -I PREROUTING -p tcp --dport 80 -s 192.168.1.2 -j DNAT --to-destination 192.168.1.1:80 it works perfectly.. but I want to redirect only for one URL like this: iptables -t nat -I PREROUTING -p tcp --dport 80 -s 192.168.1.2 -m string --string "google.com" -j DNAT --to-destination 192.168.1.1:80 which does not work in any way... please help me with this

    Read the article

  • Add String to adapter

    - by Waggoner_Keith
    I have an adapter and i want to add a string to it but when i run this code it only add the last string in the songstoadd variable ... That is a custom adapter which adds dividers in where neccessary but in the Array Adapter i want to a all of the strings that have the same first letter in their name .... SeparatedListAdapter adapter = new SeparatedListAdapter(this); ArrayList<String> songstoadd = new ArrayList<String>(); Collections.sort(songtitle); int m = 0; while( m <songtitle.size()-1){ if(songtitle.get(m).substring(0, 1) == songtitle.get(m+1).substring(0, 1)){ m++; }else{ songstoadd.clear(); songstoadd.add(songtitle.get(m)); adapter.addSection(songtitle.get(m).substring(0, 1), new ArrayAdapter<String>(getApplicationContext(),R.layout.song, songstoadd)); m++; } } setListAdapter(adapter); }

    Read the article

  • how many times a word appears into a txt file

    - by m4g4bu
    I've a problem when i tried to count how many time a word appears into a txt file. 1/ I create a textfield ( txta ) 2/ I create a button to apply the action ( btn ) 3/ I create a textarea ( area ) that is the place where the content of the file is displayed When I select the file, the content of the file is displayed on area, then I enter the word in txta to search and then I clicked the btn but the code is not working public int contarPalabras(String chain, String word) { // Recibe un string y una palabra y devuelve la cantidad de veces que encontró esa palabra en el string. // Si no encuentra la letra devuelve (-1). int cant = 0; int intIndex = chain.indexOf(word); if(intIndex == - 1){ cant = -1; }else{ cant = intIndex; } return cant; }

    Read the article

  • how to test if a string is a valid UTF16 string?

    - by superb
    I am using mongodb and javascript to do some string processing. Now I got some error like: Sun May 23 07:42:20 Assertion failure JS_EncodeCharacters( _context , s , srclen , dst , &len) scripting/engine_spidermonkey.cpp 152 0x80f4f7e 0x80f8794 0x811525b 0x811a953 0x8119fc4 0x8111bc5 0x81b408e 0x81c4ee7 0x81b4a10 0x817a881 0x817a7d8 0x817a6e2 0x811e1bb 0x80a777b 0x80a8f8a 0xb7cb2455 0x80a37a1 mongodb-linux-i686-1.4.2/bin/mongo(_ZN5mongo12sayDbContextEPKc+0xfe) [0x80f4f7e] After doing some google, I find that JS_EncodeCharacters return false if the input is not a valid UTF16 string. (if spidermonkey is build with UTF-8 enabled) So I was wondering how to test if the input string if a proper UTF16 string? so I can skip such kind of string to avoid problem ... Thanks

    Read the article

  • Coldfusion: how to extract a substring using regex

    - by justNeo
    I have a string that has some double quoted substring in it, the " character. In between the double quotes is the data i want. How can i write a regex to extract "the first data i want" and "the second data i want" from this: 'some string with "the first data i want" and "the second data i want"' I tried the following code. <cfset mydata = 'some string with "the first data i want" and "the second data i want"'/> <cfset arrData = ListToArray(mydata ,'"') />

    Read the article

  • How to lowercase every element of a collection efficiently?

    - by Chris
    Whats the most efficient way to lower case every element of a list or set? My idea for a List: final List<String> strings = new ArrayList<String>(); strings.add("HELLO"); strings.add("WORLD"); for(int i=0,l=strings.size();i<l;++i) { strings.add(strings.remove(0).toLowerCase()); } is there a better, faster way? How would this exmaple look like for a set? As there is currently no method for applying an operation to each element of a set (or list) can it be done without creating an additional temporary set? Something like this would be nice: Set<String> strings = new HashSet<String>(); strings.apply( function (element) { this.replace(element, element.toLowerCase();) } ); Thanks,

    Read the article

  • casting BSTR as char* in a dll; different results depnding on VB/C# caller.

    - by Toby Wilson
    I have a dll function that takes BSTR parameters. These are casted as char* before being used for other things. When the dll is called from VB code this works fine. However, when it is called from C# code, only the first character is pointed to. Both of these are excel addIns for Pre-2007 and 2007+ versions of Office, which call into a faster C++ AddIn. They actually call it directly, not through Excel. The VB function declaration looks like this: Private Declare Function Test Lib "ExcelAddIn.xll" (ByVal param As String) As String The C# function declaration looks like this: [DllImport("ExcelAddIn.xll", CharSet=CharSet.Ansi)] [return:MarshalAs(UnmanagedType.BStr)] private static extern string Test([MarshalAs(UnmanagedType.BStr)] string param); When debugging the dll and watching the input BSTR values, they appear to be correct from both; just the C# one only casts the first character. Charset=CharSet.Unicode makes no difference. Any ideas anyone?

    Read the article

  • Comparing strings that contain formatting in C#

    - by Finglas
    I'm working on a function that given some settings - such as line spacing, the output (in string form) is modified. In order to test such scenarios, I'm using string literals, as shown below for the expected result. The method, using a string builder, (AppendLine) generates the said output. One issue I have run into is that of comparing such strings. In the example below, both are equal in terms of what they represent. The result is the area which I care about, however when comparing two strings, one literal, one not, equality naturally fails. This is because one of the strings emits line spacing, while the other only demonstrates the formatting it contains. What would be the best way of solving this equality problem? I do care about formatting such as new lines from the result of the method, this is crucially important. Code: string expected = @"Test\n\n\nEnd Test."; string result = "Test\n\n\nEnd Test"; Console.WriteLine(expected); Console.WriteLine(result); Output: Test\n\n\nEnd Test. Test End Test

    Read the article

  • How can i convert a string into byte[] of unsigned int 32 C#

    - by Miroo
    i have string like "0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF" i wanna convert it into byte[] key= new byte[] { 0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF}; i thought about splitting the string by ',' then loop on it and setvalue into another byte[] in index of i string Key = "0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF"; string[] arr = Key.Split(','); byte[] keybyte= new byte[8]; for (int i = 0; i < arr.Length; i++) { keybyte.SetValue(Int32.Parse(arr[i].ToString()), i); } but seems like it doesn't work i get error in converting the string into unsigned int32 on the first beginning an help would be appreciated

    Read the article

  • SQL Connection String to access localhost\SQLEXPRESS

    - by user34683
    I've installed SQL Express on my PC hoping to do some practice creating tables and then modifying them. I coded a webpage in Visual Studio to, basically, SELECT * from a table in the SQLEXPRESS, but I can never get the connection string to work. Please help My connection string "Data Source=localhost\SQLEXPRESS;Initial Catalog=test;User Id=xaa9-PC\xaa9;Password=abcd;" Error Message: Query is select * from tblCustomers where username='johndoe' error is Login failed for user 'xaa9-PC\xaa9'.

    Read the article

  • Newline not showing correctly in textbox

    - by TheGateKeeper
    I am loading a string from my database which among other things contains line breaks (\r\n). However, this isn't being rendered as a new line but instead as \r\n. If I type it directly in instead of loading it from a string, it works just fine but I need to be able to load it from a string. Any ideas? Edit: Upon closer inspection, it looks like the string is being returned as: Changed test7\\r\\nChanged test8\\r\\nChanged test9Changed test7 From the database. I tried running a .Replace(@"\\", @"\") on it but this had no effect at all. Any ideas?

    Read the article

  • What is an efficient way to erase substrings?

    - by Legend
    I have a long string and a set of <end-index, string> list like the following: long_sentence = "This is a long long long long sentence" indices = [[6, "is"], [8, "is a"], [18, "long"], [23, "long"]] An element 6, "is" indicates that 6 is the end index of the word "is" in the string. I want to get the following string in the end: >> print long_sentence This .... long ......... long sentence" I tried an approach like this: temp = long_sentence for i in indices: temp = temp[:int(i[0]) - len(i[1])] + '.'*(len(i[1])+1) + temp[i[0]+1:] While this seems to be working, it is taking exceptionally long time (more than 6 hours on 5000 strings inside a 300 MB file). Is there a way to speed this up?

    Read the article

  • error string list handle in C#

    - by Chelsea_cole
    Same namespace: 2 forms. public class Account //frm1 { public string Username; public string Password; } public class ListAcc { public static List<Account> UserList; } private void button1_Click(object sender, EventArgs e) { List<Account> UserList = new List<Account>(); Account acc = new Account(); acc.Username = textBox1.Text; acc.Password = textBox2.Text; UserList.Add(acc); } private void button2_Click(object sender, EventArgs e) //frm2 { string p = frmDangky.ListAcc.UserList[0].Username; // null ->error string p = frmDangky.ListAcc.UserList[0].Password; // null ->error } Someone help me? :( why my string is NULL???????? The textBox is not empty... Thanks!

    Read the article

  • javascript split() array contains

    - by Mahesha999
    While learning JavaScript, I did not get why the output when we print the array returned of the Sting.split() method (with regular expression as an argument) is as explained below. var colorString = "red,blue,green,yellow"; var colors = colorString.split(/[^\,]+/); document.write(colors); //this print 7 times comma: ,,,,,,, However when I print individual element of the array colors, it prints an empty string, three commas and an empty string: document.write(colors[0]); //empty string document.write(colors[1]); //, document.write(colors[2]); //, document.write(colors[3]); //, document.write(colors[4]); //empty string document.write(colors[5]); //undefined document.write(colors[6]); //undefined Then, why printing the array directly gives seven commas. Though I think its correct to have three commas in the second output, I did not get why there is a starting (at index 0) and ending empty string (at index 4). Please explain I am screwed up here.

    Read the article

  • Ravendb 960 does not honor JsonIgnore with property of Dictionary<string, object>

    - by David Robbins
    Does JsonIgnore not work when a property has data? I have the followin class: public class SomeObject { public string Name { get; set; } public DateTime Created { get; set; } public List<string> ErrorList { get; set; } [JsonIgnore] public Dictionary<string, object> Parameters { get; set; } public SomeObject() { this.ErrorList = new List<string>(); this.Parameters = new Dictionary<string, object>(); } } My expectation was that JsonIgnore would exclude properties from De- / Serialization. My RavenDB document has data. Am I missing something?

    Read the article

  • Removing whitespace in Java string?

    - by waitinforatrain
    Hi guys, I'm writing a parser for some LISP files. I'm trying to get rid of leading whitespace in a string. The string contents are along the lines of: :FUNCTION (LAMBDA (DELTA PLASMA-IN-0) (IF (OR (>= #61=(+ (* 1 DELTA) PLASMA-IN-0) 100) (<= #61# 0)) PLASMA-IN-0 #61#)) The tabs are all printed as 4 spaces in the file, so I want to get rid of these leading tabs. I tried to do this: string.replaceAll("\\s{4}", " ") - but it had no effect at all on the string. Does anyone know what I'm doing wrong? Is it because it is a multi-line string? Thanks

    Read the article

  • app.config and 64-bit machines

    - by Dale Lutes
    I have an app that works fine on 32-bit systems, but fails on XP 64 bit systems. I've tracked it down to the connection string defined in my app.config thus: <connectionStrings> <clear/> <add name="IFDSConnectionString" connectionString="Data Source=fdsdata;Initial Catalog=IFDS; Trusted_Connection=true;Connect Timeout=0" providerName="System.Data.SqlClient" /> </connectionStrings> When I try to reference it in code, I find that the ConfigurationManager.ConnectionStrings collection only contains the LocalSqlServer connection string from the machine.config file and not my custom string. Another oddity is that it works fine when I run the app out of Visual Studio. It is only when I run out of the release folder that the connection string does not get defined. The application's .exe.config file is there in the release folder along with the .exe file and is up to date.

    Read the article

  • Reading a part of a alpha numeric string in SQL

    - by novice
    I have a table with one column " otname " table1.otname contains multiple rows of alpha-numeric string resembling the following data sample: 11.10.32.12.U.A.F.3.2.21.249.1 2001.1.1003.8281.A.LE.P.P 2010.1.1003.8261.A.LE.B.B I want to read the fourth number in every string ( part of the string in bold ) and write a query in Oracle 10g to read its description stored in another table. My dilemma is writing the first part of the query.i.e. choosing the fourth number of every string in a table My second query will be something like this: select description_text from table2 where sncode = 8281 -- fourth part of the data sample in every string Many thanks. novice

    Read the article

  • Phase REST XML into variable

    - by 001
    I want to get a response from the REST XML web service, and phase it into variables so I can use them in my program. 1) How come this code does not work? I get an empty string... // Get response string ws_response=""; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { // Get the response stream StreamReader reader = new StreamReader(response.GetResponseStream()); // web service response string ws_response = reader.ReadToEnd; // <---???? I get an empty string // do phasing here (ie XML element into variable) etc.. // }

    Read the article

  • is there any faster way to parse than by walk each byte?

    - by uray
    is there any faster way to parse a text than by walk each byte of the text? I wonder if there is any special CPU (x86/x64) instruction for string operation that is used by string library, that somehow used to optimize the parsing routine. for example instruction like finding a token in a string that could be run by hardware instead of looping each byte until a token is found.

    Read the article

  • Foreach wont split a string

    - by Luke
    //assign variables string measurementIn; //read in file in array string[] lines = File.ReadAllLines("../../convert.txt"); //ask user for date Console.WriteLine("Enter the conversion in the form (amount,from,to)"); measurementIn = Console.ReadLine(); //array for splitting input string[] conversionArray = measurementIn.Split(','); Console.WriteLine("{0} , {1} , {2}", conversionArray[0], conversionArray[1], conversionArray[2]); Console.ReadLine(); //check lines for conversion foreach (string line in lines) { //array for the measurement string[] measurementArray = line.Split(','); Console.WriteLine("{0}", measurementArray[0]);

    Read the article

  • Efficient determination of which strings in an array are substrings of the others?

    - by byte
    In C#, Say you have an array of strings, which contain only characters '0' and '1': string[] input = { "0101", "101", "11", "010101011" }; And you'd like to build a function: public void IdentifySubstrings(string[] input) { ... } That will produce the following: "0101 is a substring of 010101011" "101 is a substring of 0101" "101 is a substring of 010101011" "11 is a substring of 010101011" And you are NOT able to use built-in string functionality (such as String.Substring). How would one efficiently solve this problem? Of course you could plow through it via brute force, but it just feels like there ought to be a way to accomplish it with a tree (since the only values are 0's and 1's, it feels like a binary tree ought to fit somehow). I've read a little bit about things like suffix trees, but I'm uncertain if that's the right path to be going down. Any efficient solutions you can think of?

    Read the article

  • How to get the substring in C#?

    - by Nano HE
    Hi, I can get the first three characters with the function below. However, how can I get the output of the last five characters (Three) with Substring() function. Or other string function will be used? Thank you. static void Main() { string input = "OneTwoThree"; // Get first three characters string sub = input.Substring(0, 3); Console.WriteLine("Substring: {0}", sub); // Output One. }

    Read the article

  • Adapting pseudocode to java implementation for finding the longest word in a trie

    - by user1766888
    Referring to this question I asked: How to find the longest word in a trie? I'm having trouble implementing the pseudocode given in the answer. findLongest(trie): //first do a BFS and find the "last node" queue <- [] queue.add(trie.root) last <- nil map <- empty map while (not queue.empty()): curr <- queue.pop() for each son of curr: queue.add(son) map.put(son,curr) //marking curr as the parent of son last <- curr //in here, last indicate the leaf of the longest word //Now, go up the trie and find the actual path/string curr <- last str = "" while (curr != nil): str = curr + str //we go from end to start curr = map.get(curr) return str This is what I have for my method public static String longestWord (DTN d) { Queue<DTN> holding = new ArrayQueue<DTN>(); holding.add(d); DTN last = null; Map<DTN,DTN> test = new ArrayMap<DTN,DTN>(); DTN curr; while (!holding.isEmpty()) { curr = holding.remove(); for (Map.Entry<String, DTN> e : curr.children.entries()) { holding.add(curr.children.get(e)); test.put(curr.children.get(e), curr); } last = curr; } curr = last; String str = ""; while (curr != null) { str = curr + str; curr = test.get(curr); } return str; } I'm getting a NullPointerException at: for (Map.Entry<String, DTN> e : curr.children.entries()) How can I find and fix the cause of the NullPointerException of the method so that it returns the longest word in a trie?

    Read the article

< Previous Page | 97 98 99 100 101 102 103 104 105 106 107 108  | Next Page >