Search Results

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

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

  • Java: Match tokens between two strings and return the number of matched tokens

    - by Cryssie
    Need some help to find the number of matched tokens between two strings. I have a list of string stored in ArrayList (example given below): Line 0 : WRB VBD NN VB IN CC RB VBP NNP Line 1 : WDT NNS VBD DT NN NNP NNP Line 2 : WRB MD PRP VB DT NN IN NNS POS JJ NNS Line 3 : WDT NN VBZ DT NN IN DT JJ NN IN DT NNP Line 4 : WP VBZ DT JJ NN IN NN Here, you can see each string consists of a bunch of tokens separated by spaces. So, there's three things I need to work with.. Compare the first token (WRB) in Line 0 to the tokens in Line 1 to see if they match. Move on to the next tokens in Line 0 until a match is found. If there's a match, mark the matched tokens in Line 1 so that it will not be matched again. Return the number of matched tokens between Line 0 and Line 1. Return the distance of the matched tokens. Example: token NN is found on position 3 on line 0 and position 5 on Line 1. Distance = |3-5| = 2 I've tried using split string and store it to String[] but String[] is fixed and doesn't allow shrinking or adding of new elements. Tried Pattern Matcher but with disasterous results. Tried a few other methods but there's some problems with my nested for loops..(will post part of my coding if it will help). Any advice or pointers on how to solve this problem this would be very much appreciated. Thank you very much.

    Read the article

  • How can I capture multiple matches from the same Perl regex?

    - by Sho Minamimoto
    I'm trying to parse a single string and get multiple chunks of data out from the same string with the same regex conditions. I'm parsing a single HTML doc that is static (For an undisclosed reason, I can't use an HTML parser to do the job.) I have an expression that looks like: $string =~ /\<img\ssrc\="(.*)"/; and I want to get the value of $1. However, in the one string, there are many img tags like this, so I need something like an array returned (@1?) is this possible?

    Read the article

  • Why does this program crash: passing of std::string between DLLs

    - by msiemeri
    Hello together. I have some trouble figuring out why the following crashes (MSVC9): //// the following compiles to A.dll with release runtime linked dynamically //A.h class A { __declspec(dllexport) std::string getString(); }; //A.cpp #include "A.h" std::string A::getString() { return "I am a string."; } //// the following compiles to main.exe with debug runtime linked dynamically #include "A.h" int main() { A a; std::string s = A.getString(); return 0; } // crash on exit Obviously (?) this is due to the different memory models for the executable and DLL. Could it be that the string A::getString() returns is being allocated in A.dll and freed in main.exe? If so, why - and what would be a safe way to pass strings between DLLs (or executables, for that matter)? Without using wrappers like shared_ptr with a custom deleter.

    Read the article

  • How to delete characters and append strings?

    - by devin250
    i am adding a new record to xml file im first quering all existing items and storing the count in an int int number = query.count() and then incrementing number by 1; number = number +1; now i want to format this value in a string having "N00000000" format and the number will ocuppy the last positions Pseudo code: //declare the format string sting format = "N00000000" //calculate the length of number string int length =number.ToString().Length(); // delete as many characters from right to left as the length of number string ??? // finally concatenate both strings with + operator ??? help please

    Read the article

  • Python lambda returning None instead of empty string

    - by yoshi
    I have the following lambda function: f = lambda x: x == None and '' or x It should return an empty string if it receives None as the argument, or the argument if it's not None. For example: >>> f(4) 4 >>> f(None) >>> If I call f(None) instead of getting an empty string I get None. I printed the type of what the function returned and I got NoneType. I was expecting string. type('') returns string, so I'd like to know why the lambda doesn't return an empty string when I pass None as an argument. I'm fairly new to lambdas so I might have misunderstood some things about how they work.

    Read the article

  • How do I read text from a serial port?

    - by user2164
    I am trying to read data off of a Windows serial port through Java. I have the javax.comm libraries and am able to get some data but not correct data. When I read the port into a byte array and convert it to text I get a series of characters but no real text string. I have tried to specify the byte array as being both "UTF-8" and "US-ASCII". Does anyone know how to get real text out of this? Here is my code: while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); System.out.println("Reading from " + portId.getName() + ": "); System.out.println("Read " + numBytes + " bytes"); } System.out.println(new String(readBuffer)); System.out.println(new String(readBuffer, "UTF-8")); System.out.println(new String(readBuffer, "US-ASCII")); the output of the first three lines will not let me copy and paste (I assume because they are not normal characters). Here is the output of the Hex: 78786000e67e9e60061e8606781e66e0869e98e086f89898861878809e1e9880 I am reading from a Hollux GPS device which does output in string format. I know this for sure because I did it through C#. The settings that I am using for communication which I know are right from the work in the C# app are: Baud Rate: 9600 Databits: 8 Stop bit: 1 parity: none

    Read the article

  • What is wrong with this c# method?

    - by bala3569
    I use this method to get file extension, public string ReturnExtension(string fileExtension) { switch (fileExtension) { case ".doc": case ".docx": return "application/ms-word"; } } When i compile it i got the error BaseClass.ReturnExtension(string)': not all code paths return a value.. Any suggestion...

    Read the article

  • strtok wont accept: char *str

    - by bks
    strtok wont work correctly when using char *str as the first parameter (not the delimiters string). does it have something to do with the area that allocates strings in that notation? (which as far as i know, is a read-only area). thanks in advance example: //char* str ="- This, a sample string."; // <---doesn't work char str[] ="- This, a sample string."; // <---works char delims[] = " "; char * pch; printf ("Splitting string \"%s\" into tokens:\n",str); pch = strtok (str,delims); while (pch != NULL) { printf ("%s\n",pch); pch = strtok (NULL, delims); } return 0;

    Read the article

  • Missing backslashes in filename using C#

    - by CL4NCY
    Hi, I have a string literal as follows: string filename = @"C:\myfolder\myfile.jpg"; When I use File.Exists(filename) it works most of the time but sometimes I get an error saying the following file doesn't exist: C:myfoldermyfile.jpg Something seems to strip the backslashes out of the filename. This code is sometimes accessed via an ajax request. Does anyone know why/how this could be happening? Edit: Here is a more detailed version of the code. public class Feeds { public static string ftpDir = @"C:\website\Feeds\"; } public class Feed { public static void run(string name) { if (!Directory.Exists(Feeds.ftpDir + name)){ Response.Write("Feed doesn't exist '" + Feeds.ftpDir + name + "'"); return; } //run feed... } }

    Read the article

  • Using a function with variable argument strings

    - by wrongusername
    I was playing around a bit with functions with variable arguments, and decided to make a function to create vectors with the arguments. My function for creating an int vector worked... vector<int> makeIntVector(int numArgs, ...) { va_list listPointer; va_start(listPointer, numArgs); vector<int> made; for(int a = 0; a < numArgs; a++) made.push_back(va_arg(listPointer, int)); va_end(listPointer); return made; } but not my function for creating a string vector: vector<string> makeStringVector(int numArgs, string something, ...) { va_list listPointer; va_start(listPointer, something); vector<string> made; for(int a = 0; a < numArgs; a++) made.push_back(va_arg(listPointer, string)); va_end(listPointer); return made; } which crashes the program. What am I doing wrong?

    Read the article

  • Prevent query string manipulation by adding a hash?

    - by saille
    To protect a web application from query string manipulation, I was considering adding a query string parameter to every url which stores a SHA1 hash of all the other query string parameters & values, then validating against the hash on every request. Does this method provide strong protection against user manipulation of query string values? Are there any other downsides/side-effects to doing this? I am not particularly concerned about the 'ugly' urls for this private web application. Url's will still be 'bookmarkable' as the hash will always be the same for the same query string arguments. This is an ASP.NET application.

    Read the article

  • linux + find word/string in file under directory

    - by yael
    I have the following command find /var -type f -exec grep "param1" {} \; -print With this command I can find the param1 string in any file under /var but the time that it take for this is very long -? I need other possibility to find string in file but much more faster then my example THX yael

    Read the article

  • Working with strings in C++

    - by Elliot Bonneville
    Hi. I'm working with strings in C++. I recently came across a problem when entering strings. I'm using cin >> string; to get my string as user input. When the user enters a space into the string, the next input is automatically filled out with the remaining letters, or sometimes left blank. As the next input string is often an integer, this will result in an unpleasant bug. What's a good fix for this?

    Read the article

  • C# programatically using a string as object name when instantiating an object

    - by emk
    This is a contrived example, but lets say I have declared objects: CustomObj fooObj; CustomObj barObj; CustomObj bazObj; And I have an string array: string[] stringarray = new string[] {"foo","bar","baz"}; How can I programatically access and instantiate those objects using the string array, iterating using something like a foreach: foreach (string i in stringarray) { `i`Obj = new CustomObj(i); } Hope the idea I'm trying to get across is clear. Is this possible in C#? Thanks in advance.

    Read the article

  • Please help get this msdn function working to create an auto complete method

    - by Phil
    Here is a method from msdn to provide data to an autocomplete extender / textbox: <System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()> _ Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String() ' Create array of movies Dim movies() As String = {"Star Wars", "Star Trek", "Superman", "Memento", "Shrek", "Shrek II"} ' Return matching movies Return From m In movies(6) Where _ (m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase)) Select m).Take(count).ToArray() End Function The errors are: m.StartsWith - ('Startswith' is not a member of 'Char') Select m - ('Select Case' must end with a matching end select) .Take(count).ToArray() - (End of statement expected) Can you please let me know how to get this function working? Thanks

    Read the article

  • Javascript replace

    - by Webby
    Hello struggling here guys.. Is it possible to string replace anything between the the first forward slashes with "" but keep the rest? e.g. var would be string "/anything-here-this-needs-to-be-replaced123/but-keep-this"; would end up like this string "/but-keep-this"; Hope that made sence

    Read the article

  • Dynamically formatting a string

    - by TofuBeer
    Before I wander off and roll my own I was wondering if anyone knows of a way to do the following sort of thing... Currently I am using MessageFormat to create some strings. I now have the requirement that some of those strings will have a variable number of arguments. For example (current code): MessageFormat.format("{0} OR {1}", array[0], array[1]); Now I need something like: // s will have "1 OR 2 OR 3" String s = format(new int[] { 1, 2, 3 }); and: // s will have "1 OR 2 OR 3 OR 4" String s = format(new int[] { 1, 2, 3, 4 }); There are a couple ways I can think of creating the format string, such as having 1 String per number of arguments (there is a finite number of them so this is practical, but seems bad), or build the string dynamically (there are a lot of them so this could be slow). Any other suggestions?

    Read the article

  • Double.Parse - Internationalization problem

    - by oz
    This is driving me crazy. I have the following string in a ASP.NET 2.0 WebForm Page string s = "0.009"; Simple enough. Now, if my culture is Spanish - which is "es-ES" - and I try to convert the string to Double, I do the following: double d = Double.Parse(s, new CultureInfo("es-ES")); what I'd expect is 0,009. Instead, I get 9. I understand that .NET thinks it is a thousand separator, which in en-US is a comma, but shouldn't it take the culture info I'm passing to the parse method and apply the correct format to the conversion? If I do double d = 0.009D; string formatted = d.ToString(new CultureInfo("es-ES")); formatted is now 0,009. Anybody?

    Read the article

  • String Constant Pool memory sector and garbage collection

    - by WickeD
    I read this question on the site How is the java memory pool divided? and i was wondering to which of these sectors does the "String Constant Pool" belongs? And also does the String literals in the pool ever get GCed? The intern() method returns the base link of the String literal from the pool. If the pool does gets GCed then wouldn't it be counter-productive to the idea of the string pool? New String literals would again be created nullifying the GC. (It is assuming that only a specific set of literals exist in the pool, they never go obsolete and sooner or later they will be needed again)

    Read the article

  • How to overwrite specific lines on text files

    - by iTayb
    I have two text files. I'd like to copy a specific part in the first text file and replace it with a part of the second text file. This is how I read the files: List<string> PrevEp = File.ReadAllLines(string.Format(@"{0}naruto{1}.ass", url, PrevEpNum)).ToList(); List<string> Ep = File.ReadAllLines(string.Format(@"{0}naruto{1}.ass", url, EpNum)).ToList(); The part in PrevEp that I need: from the start until it meets a line that includes Creditw,,0000,0000,0000. The part I would like to overwrite in Ep: from the start to a line which is exactly Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text. I'm not so sure how may I do it. Could you lend me a hand? Thank you very much, gentlemen.

    Read the article

  • Expression.Call() to String.Equals() throws error

    - by Sam
    The following code: var constant = Expression.Constant("find me", typeof(string)); // memberExpression evaluates to a string var predicate = Expression.Call(memberExpression, "Equals", null, constant); is throwing the error More than one method 'Equals' on type 'System.String' is compatible with the supplied arguments. I'm guessing that's because there's Equals(Object) and Equals(String) - is there any way for me to specify which method I mean to use via the overload of Expression.Call() that takes an instance method name as a string? Or do I have to make a special case for calls to Equals() to take a MethodInfo instead?

    Read the article

  • Split with token info

    - by boomhauer
    I would like to split a string using multiple chars to split upon. For example, consider spin text format: This is a {long|ugly|example} string I would want to parse this string and split it on the "{", "|", and "}" chars myString.Split('|','{','}') Now I have tokens to play with, but what I would like is to retain the info about which char was used to split each piece of the array that is returned. Any existing code that can do something like this?

    Read the article

  • Nhibernate ValueType Collection as delimited string in DB

    - by JWendel
    Hi I have a legacy db that I am mapping with Nhibernate. And in several locations a list och strigs or domain objects are mapped as a delimited string in the database. Either 'string|string|string' in the value type cases and like 'domainID|domainID|domainID' in the references type cases. I know I can create a dummy property on the class and map to that fields but I would like to do it in a more clean way, like when mapping Enums as their string representation with the EnumStringType class. Is a IUserType the way to go here? Thanks in advance /Johan

    Read the article

  • Replace text in string with delimeters using Regex

    - by user1057735
    I have a string something like, string str = "(50%silicon +20%!(20%Gold + 80%Silver)| + 30%Alumnium)"; I need a Regular Expression which would Replace the contents in between ! and | with an empty string. The result should be (50%silicon +20% + 30%Alumnium). If the string contains something like (with nested delimiters): string str = "(50%silicon +20%!(80%Gold + 80%Silver + 20%!(20%Iron + 80%Silver)|)| + 30%Alumnium)"; The result should be (50%silicon +20% + 30%Alumnium) - ignoring the nested delimiters. I've tried the following Regex, but it doesn't ignore the nesting: Regex.Replace(str , @"!.+?\|", "", RegexOptions.IgnoreCase);

    Read the article

  • How to reverse a string?

    - by WM
    Example : hi how are you; output : you are how hi; but wrote this code and im stuck not knowing how to put a string into an array and reverse it..? public class Reverse { public static void main(String[] args) { Scanner text = new Scanner(System.in); System.out.print("Enter your Text : "); String input = text.nextLine(); Scanner text2 = new Scanner(text.nextLine()); String[] array = new String[] ; int i; for(i = 0; i < input.length(); i++) { array[i] = input;

    Read the article

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