Search Results

Search found 44874 results on 1795 pages for 'string format'.

Page 30/1795 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • sed: delete text between a string until first occurrence of another string

    - by Marit Hoen
    Imagine I have something like the following text: The quick brown fox jumps in 2012 and 2013 And I would wish to delete the part from "fox" including the four numbers but only in the first occurrence so I end up with: The quick brown and 2013 Something likes this...: echo "The quick brown fox jumps in 2012 and 2013" \ | sed "s/fox.*\([0-9]\{4\}\)//g" ...brings me: The quick brown So it removed everything including the last occurrence of the four numbers. Any ideas?

    Read the article

  • String search and write into file in jython

    - by kdev
    hi Everyone , i wish to write a program that can read a file and if a particular str_to_find is found in a bigger string say AACATGCCACCTGAATTGGATGGAATTCATGCGGGACACGCGGATTACACCTATGAGCAGAAATACGGCCTGCGCGATTACCGTGGCGGTGGACGTTCTTCCGCGCGTGAAACCGCGATGCGCGTAGCGGCAGGGGCGATCGCCAAGAAATACCTGGCGGAAAAGTTCGGCATCGAAATCCGCGGCTGCCTGACCCAGATGGGCGACATTCCGCTGGAGATTAAAGACTGGCGTCAGGTTGAGCTTAATCCGTTTTC then write that line and the above line of it into the file and keep repeating it for all the match found. Please suggest i have written the program for printing that particular search line but i dont know how to write the above line. Thanks everyone for your help. import re import string file=open('C:/Users/Administrator/Desktop/input.txt','r') output=open('C:/Users/Administrator/Desktop/output.txt','w') count_record=file.readline() str_to_find='AACCATGC' while count_record: if string.find(list,str_to_find) ==0: output.write(count_record) file.close() output.close()

    Read the article

  • Best way to create SEO friendly URI string

    - by Mat Banik
    The method below allows only "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-" chars in URI strings. What better way is there to make nice SEO URI string? import org.apache.commons.lang.StringUtils; public static String safeChar(String input) { input = input.trim(); input = StringUtils.replace(input, " -", "-"); input = StringUtils.replace(input, "- ", "-"); input = StringUtils.replace(input, " - ", "-"); input = StringUtils.replaceChars(input, '\'', '-'); input = StringUtils.replaceChars(input, ' ', '-'); char[] allowed = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-".toCharArray(); char[] charArray = input.toCharArray(); StringBuilder result = new StringBuilder(); for (char c : charArray) { for (char a : allowed) { if (c == a) result.append(a); } } return result.toString(); }

    Read the article

  • Dictionary<string,string> to Dictionary<Control,object> using IEnumerable<T>.Select()

    - by abatishchev
    I have a System.Collections.Generic.Dictionary<string, string> containing control ID and appropriate data column to data bind: var dic = new Dictionary<string, string> { { "Label1", "FooCount" }, { "Label2", "BarCount" } }; I use it that way: var row = ((DataRowView)FormView1.DataItem).Row; Dictionary<Control, object> newOne = dic.ToDictionary( k => FormView1.FindControl(k.Key)), k => row[k.Value]); So I'm using IEnumerable<T>.ToDictionary(Func<T>, Func<T>). Is it possbile to do the same using IEnumerable<T>.Select(Func<T>) ?

    Read the article

  • MATLAB: dealing with java.lang.String

    - by Jason S
    I seem to be stuck in Kafka-land, with a java.lang.String that I can't seem to use in MATLAB functions: K>> name name = Jason K>> sprintf('%s', name) ??? Error using ==> sprintf Function is not defined for 'java.lang.String' inputs. K>> ['my name is ' name] ??? Error using ==> horzcat The following error occurred converting from char to opaque: Error using ==> horzcat Undefined function or method 'opaque' for input arguments of type 'char'. how can I get a java.lang.String to convert to a regular MATLAB character array?

    Read the article

  • How to pass a very long string/file into RESTWebservice JAX-RS Jersey

    - by Sashikiran Challa
    Hello All, I am trying to write a webservice that takes in an XML string, does parsing of it using DOM and extract particular things I want. My XML string happens to be very long so I do not want to pass it as a @QueryParam or @PathParam. Say If I write that XML string into a file, How do I go about writing a RESTful service that takes in this file, extracts whatever I want and return the results. I am actually trying to extract some number of strings, so my output should probably be an ArrayList having all these strings. Could somebody please shed some light on how I should go about doing this. Thanks in advance

    Read the article

  • Convert From Custom List to List of String

    - by Paul Johnson
    Hi all I have the following code: Public Shared Function ConvertToString(ByVal list As IList) As String Dim strBuilder = New System.Text.StringBuilder() Dim item As Object For Each item In list strBuilder.Append(obj.ToString()) strBuilder.Append(",") Next Return strBuilder.ToString(strBuilder.Length - 1) End Function The intention is to convert an IList of custom objects to a string equivalent comprising each element in the Ilist. Unfortunately I can't seem to find a way to get the underlying data of the custom object, and of course as in the above example, using object simply gives me a string of types definitions, rather than access to the underlying data. Any assistance much appreciated. Paul.

    Read the article

  • Visual Studio does not flag unterminated string constant in VB.Net

    - by JoelFan
    I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e. Dim foo as String = "hi However, the continuous integration tool we are using flags an error: error BC30648: String constants must end with a double quote. What's going on here? Is there some language rule in VB.NET that makes a terminating double quote optional "sometimes"? Is there some setting in Visual Studio that will make it flag this as an error?

    Read the article

  • Replace letters in a secret text

    - by kame
    Hello! I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor problem with y and z. import string letters = string.ascii_lowercase text=("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj. ") for x in range(1,24): text.replace(letters[x],letters[x+2]) print(text)

    Read the article

  • Sending a JSON array to be received as a Dictionary<string,string>

    - by James Bond
    I have a method with the following signature: public ActionResult RenderFamilyTree(string name, Dictionary<string, string> children) I'm trying to call it from javascript using jQuery like this: $('#div_render').load( "<%= Url.Action("RenderFamilyTree") %>", { 'name': 'Raul', [ {'key':'key1','value':'value1'}, {'key':'key2','value':'value2'} ] }, function() { alert('Loaded'); } ); Am I missing something to get this to work?

    Read the article

  • checking last char of string in c

    - by radar75
    If I have two types of strings as: const char *str1 = "This is a string with \"quotes escaped at the end\""; const char *str2 = "This is a \"string\" without quotes at the end"; testFn(str1); testFn(str2); int testFn(char *str) { // test & return 1 if ends on no quote // test & return 0 if ends on quote return; } I would like to test if the string ends with a quote " or not What would be a good way of testing this? Thanks

    Read the article

  • The method split(String) is undefined for the type String

    - by pi
    I am using Pulse - the Plugin Manager for Eclipse and installed. I have the Eclipse 3.5 for mobile development(Pulsar) profile with a couple other profiles. I realized that the split() method called on a string from code such as below: String data = "one, two, three, four"; data.split(","); generates the error: "The method split(String) is undefined for the type String". I am aware that the split() method did not exist before Java's JRE 1.4 and perhaps could be the cause of the problem. The problem is I don't think I have jre/sdk versions installed. Perhaps there's one in-built with the Pulsar profile and needs editing - but I couldn't tell what settings (and where) needs tweaking. I have checked WindowsPreferencesJavaInstalled JREs and it's set to = jre1.4. Please help thanks.

    Read the article

  • Substring and its reverse in a string

    - by christa
    My professor was talking about this in a Dynamic programming class and asked us to think over it. She gave us some examples as well. Given a string, we were to find the longest continuous subsequence whose reverse is also a subsequence present in the given string. Example: INPUT: pqrstuvtsrv OUTPUT: i=3, k=2 rst -> tsr (rst found first at i=3 and for 2 more positions) INPUT: mpqrsrqp OUTPUT: i=2, k=6 pqrsrqp in reverse INPUT: mmpqssss OUTPUT: i=5, k=3 I thought of putting the string and its reverse into 2 different arrays and comparing character by character. But I'm sure this is not the best way to do it. Any suggestions as to what could be the most efficient ?

    Read the article

  • iBatis mapping: map a string field into a List<String>

    - by Roberto
    Hi all, is it possible to map a string field with a particular format like: aaa,bbb,ccc,ddd into a List having elements [aaa, bbb, ccc, ddd] using iBatis? What I need is to have in my model something like: public class Request{ private List<String> fieldOne; public List<String> getFieldOne(){....} public void setFieldOne(){....} } even if in my table the field is a simple string. Is this possible? Thanks Roberto

    Read the article

  • Getting Dictionary<string,string> from List<Control>

    - by codymanix
    I want a dictionary containing the names and text of all controls. Is it possible with predefined framework methods/LINQ/colection initializers or do I have to make a loop and add all entries by myself? This gives me an error message: List<Control> controls; // .. initialize list .. controls.ToDictionary((Control child,string k)=>new KeyValuePair<string,string>(child.Name, child.Text));

    Read the article

  • IsDouble check for string in Vb.net?

    - by James123
    I will get data in DataTable. I am going to iterate data in foreach. I will have all types of data in Datatable. Now I need to find Double for each item (string) in DataTable. How to find IsDouble for string? Ex: I have "21342.2121" string. I need to covert this to Double. But sometimes the data will be "TextString". So I can't use Double.Parse(). How to handle this?

    Read the article

  • binary file to string

    - by andrew
    i'm trying to read a binary file (for example an executable) into a string, then write it back FileStream fs = new FileStream("C:\\tvin.exe", FileMode.Open); BinaryReader br = new BinaryReader(fs); byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length)); System.Text.Encoding enc = System.Text.Encoding.ASCII; string myString = enc.GetString(bin); fs.Close(); br.Close(); System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byte[] rebin = encoding.GetBytes(myString); FileStream fs2 = new FileStream("C:\\tvout.exe", FileMode.Create); BinaryWriter bw = new BinaryWriter(fs2); bw.Write(rebin); fs2.Close(); bw.Close(); this does not work (the result has exactly the same size in bytes but can't run) if i do bw.Write(bin) the result is ok, but i must save it to a string

    Read the article

  • C++ string array binary search

    - by Jose Vega
    string Haystack[] = { "Alabama", "Alaska", "American Samoa", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Guam", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Northern Mariana Islands", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Puerto Rico", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "US Virgin Islands", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"}; string Needle = "Virginia"; if(std::binary_search(Haystack, Haystack+56, Needle)) cout<<"Found"; If I also wanted to find the location of the needle in the string array, is there an "easy" way to find out?

    Read the article

  • need identical string comparison function in php and java

    - by steelbytes
    I have sorted list of strings that I move between php and java. to be able to bsearch on this data, I need the same comparison function. any idea what string compare functions I can use that will always give the same result in both? eg php's strcmp() vs java's String.compareTo() yes I know I could make my own string compare that does char by char carefully, but I was hoping there's a simple answer. PS, don't care if case sensitive or not, as long as it is consistant.

    Read the article

  • std::string == operator not working

    - by Paul
    Hello, I've been using std::string's == operator for years on windows and linux. Now I am compiling one of my libraries on linux, it uses == heavily. On linux the following function fails, because the == returns false even when the strings are equal (case sensitive wise equal) const Data* DataBase::getDataByName( const std::string& name ) const { for ( unsigned int i = 0 ; i < m_dataList.getNum() ; i++ ) { if ( m_dataList.get(i)->getName() == name ) { return m_dataList.get(i); } } return NULL; } The getName() method is declared as follows virtual const std::string& getName() const; I am building with gcc 4.4.1 and libstdc++44-4.4.1. Any ideas? it looks perfectly valid to me. Paul

    Read the article

  • When getting substring in .Net, does the new string reference the same original string data or does

    - by Elan
    Assuming I have the following strings: string str1 = "Hello World!"; string str2 = str1.SubString(6, 5); // "World" I am hoping that in the above example str2 does not copy "World", but simply ends up being a new string that points to the same memory space only that it starts with an offset of 6 and a length of 5. In actuality I am dealing with some potentially very long strings and am interested in how this works behind the scenes for performance reasons. I am not familiar enaugh with IL to look into this.

    Read the article

  • Modify strings in Rails?

    - by Daniel O'Connor
    Hey everyone, So I'm new to Rails (teaching myself as a senior project in high school), and I'm trying to figure out how to modify these strings. Let's say someone writes the following string in a form: "you know you are a geek when" How can I automatically change it to this: "You know you are a geek when..."? I need Rails to check the case of the first letter and check for the three dots then modify the string as necessary. I've looked here, but I can't find anything that would work. Thanks a lot!

    Read the article

  • String of KML needs to be converted to java objects

    - by spartikus
    I have a string of kml coming in on a request object. I have used xjc to create the kml java objects. I am looking for an easy way to create the kml nested java objects from this string. I could parse the string and create each object in the tree by hand but wouldn't it be cool if there was a library or something that would create the java objects for me? Something like KmlType type = parseKML(mykmlStringFromTheRequest); Then type would be a Tree of kml objects. Thanks for the help all.

    Read the article

  • Converting String^ and Collection of String^ to const char*

    - by Jim Jones
    Using VS2008 Managed C++ to wrap a dll. The native method takes a series of single const char* values and a collection of char* values. Going to make an example function: Function1(char * value1, TF_StringList& catList); TF_StringList is a dll class with 3 insert methods, the one I want to use is: TF_StringList::insert(const char* str); So I set up a wrapper method of: WrapperClass::callFunction(String^ mvalue1, ArrayList mcatList); mvalue1 is converted to const char* using: const char* value1 = (char*)(Marshal::StringToHGlobalAnsi(mvalue1)).ToPointer(); However, when a get to the collection of strings, I iterate over it getting each string using the index: String^ mstr = mcatList[i]; Have tried every way of converting String^ to const char* and in every case the TF_StringList::insert(const char* str) method throws a C2663 error which has to do with the const-ness of the value. What is the problem?

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >