Search Results

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

Page 52/1447 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Javascript replace last occurence of text in a string

    - by Ruth
    Hi all see my code snippet below: var list = ['one', 'two', 'three', 'four']; var str = 'one two, one three, one four, one]; for ( var i = 0; i < list.length; i++) { if (str.endsWith(list[i]) { str = str.replace(list[i], 'finsih') } } I want to replace the last occurence of the word one with the word finish in the string, what I have will not work because the replace method will only replace the first occurence of it. Does anyone know how I can amend that snippet so that it only replaces the last instance of 'one' Thank you Ruth

    Read the article

  • How to read values from file. tokenizer

    - by user69514
    I have a file in which each line contains two numbers. The problem is that the two number are separated by a space, but the space can be any number of blank spaces. either one, two, or more. I want to read the line and store each of the numbers in a variable, but I'm not sure how to tokenize it. i.e 1 5 3 2 5 6 3 4 83 54 23 23 32 88 8 203

    Read the article

  • Splitting a string according to a delimiter when elements in the string can contain the delimiter

    - by Vivin Paliath
    I have a string that looks like this: "#Text() #SomeMoreText() #TextThatContainsDelimiter(#blah) #SomethingElse()" I'd like to get back [#Text(), #SomeMoreText(), #TextThatContainsDelimiter(#blah), #SomethingElse()] One way I thought about doing this was to require that the # to be escaped into \#, which makes the input string: "#Text() #SomeMoreText() #TextThatContainsDelimiter(\#blah) #SomethingElse()" I can then split it using /[^\\]#/ which gives me: [#Text(), SomeMoreText, TextThatContainsDelimiter(\#blah), SomethingElse()] The first element will contain # but I can strip it out. However, is there a cleaner way to do this without having to escape the #, and which ensures that the first element will not contain a #? Basically I'd like it to split by # only if the # is not enclosed by parentheses. My hunch is that since the # is context-sensitive and and regular expressions are only suited for context-free strings, this may not be the right tool. If so, would I have to write a grammar for this and roll my own parser/lexer?

    Read the article

  • Creating a short unique string for each unique long string

    - by king.net
    I'm trying to create a url shortener system in c# and asp.net mvc. I know about hashtable and I know how to create a redirect system etc. The problem is indexing long urls in database. Some urls may have up to 4000 character length, and it seems it is a bad idea to index this kind of strings. The question is: How can I create a unique short string for each url? for example MD5 can help me? Is MD5 really unique for each string? NOTE: I see that Gravatar uses MD5 for emails, so if each email address is unique, then its MD5 hashed value is unique. Is it right? Can I use same solution for urls?

    Read the article

  • JavaScript String Replace with a tricky regular expression

    - by Juri
    Hi. I'm trying to work out what regular expression I would need to change this string html = '<img style="width: 311px; height: 376px;" alt="test" src="/img/1268749322.jpg" />'; to this html = '<img width="311" height="376" alt="test" src="/img/1268749322.jpg" />'; with the help of Javascript.replace. This is my start: html = html.replace(/ style="width:\?([0-9])px*"/g, "width=\"$1\""); Can anyone help me? THANKS

    Read the article

  • Good alternative to Eregi() in PHP

    - by Click Upvote
    I often find myself doing quick checks like this: if (! eregi('.php',$fileName)) $filename.='.php'; But sadly eregi() is going to be deprecated in PHP 6, which means all of my code that uses it will be rendered useless :(. Is there another function that behaves exactly the same way as eregi()? I don't know anything about reg exps and don't want to learn, so preg_match() etc won't work for me.

    Read the article

  • Convert string to JSON using Python

    - by Luiz Fernando
    Hi, I'm a little bit confused with JSON in Python. To me, it seems like a dictionary, and for that reason I'm trying to do that: json = """{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } } """ But when I do print dict(json), it gives an error. How can I transform this string into a structure and then call json["title"] to obtain "example glossary"? Thanks.

    Read the article

  • T-SQL: Opposite to string concatenation - how to split string into multiple records

    - by kristof
    I have seen a couple of questions related to string concatenation in SQL. I wonder how would you approach the opposite problem: splitting coma delimited string into rows of data: Lets say I have tables: userTypedTags(userID,commaSeparatedTags) 'one entry per user tags(tagID,name) And want to insert data into table userTag(userID,tagID) 'multiple entries per user Inspired by Which tags are not in the database? question EDIT Thanks for the answers, actually more then one deserves to be accepted but I can only pick one, and the solution presented by Cade Roux with recursions seems pretty clean to me. It works on SQL Server 2005 and above. For earlier version of SQL Server the solution provided by miies can be used. For working with text data type wcm answer will be helpful. Thanks again.

    Read the article

  • scanf("%d", char*) - char-as-int format string?

    - by SF.
    What is the format string modifier for char-as-number? I want to read in a number never exceeding 255 (actually much less) into an unsigned char type variable using sscanf. Using the typical char source[] = "x32"; char separator; unsigned char dest; int len; len = sscanf(source,"%c%d",&separator,&dest); // validate and proceed... I'm getting the expected warning: argument 4 of sscanf is type char*, int* expected. As I understand the specs, there is no modifier for char (like %sd for short, or %lld for 64-bit long) is it dangerous? (will overflow just overflow (roll-over) the variable or will it write outside the allocated space?) is there a prettier way to achieve that than allocating a temporary int variable? ...or would you suggest an entirely different approach altogether?

    Read the article

  • Split large text string into variable length strings without breaking words and keeping linebreaks a

    - by Frank
    I am trying to break a large string of text into several smaller strings of text and define each smaller text strings max length to be different. for example: "The quick brown fox jumped over the red fence. The blue dog dug under the fence." I would like to have code that can split this into smaller lines and have the first line have a max of 5 characters, the second line have a max of 11, and rest have a max of 20, resulting in this: Line 1: The Line 2: quick brown Line 3: fox jumped over the Line 4: red fence. Line 5: The blue dog Line 6: dug under the fence. All this in C# or MSSQL, is it possible?

    Read the article

  • Append a string to the end of an element attribute using jQuery

    - by ILMV
    I have an element: <select id="row" /> I want to append a string to the end of the id attribute, like this: <select id="row_1" /> The jQuery I am using to achieve this is (from within an each): $(this).attr('id',$(this).attr('id')+'_'+row_count); This looks ugly as sin, and whilst it works I want to know if there is a simpler solution. In this example, the ID prefix (e.g. row) is never constant, so I can't just do 'row_'+row_count. Cheers!

    Read the article

  • Static string variable in Objective C on iphone

    - by Prajakta
    Hi, How to create & access static string in iPhone (objective c)? I declare static NSString *str = @"OldValue" in class A. If i assign some value to this in class B as str = @"NewValue". This value persists for all methods in class B. But if I access it in class C (after assignment in B) I am getting it as OldValue. Am I missing something? Should i use extern in other classes? Thanks & Regards, Yogini

    Read the article

  • immutable strings vs std::string

    - by Caspin
    I've recent been reading about immutable strings, here and here as well some stuff about why D chose immutable strings. There seem to be many advantages. trivially thread safe more secure more memory efficient in most use cases. cheap substrings (tokenizing and slicing) Not to mention most new languages have immutable strings, D2.0, Java, C#, Python, Ruby, etc. Would C++ benefit from immutable strings? Is it possible to implement an immutable string class in c++ (or c++0x) that would have all of these advantages?

    Read the article

  • Efficient mass string search problem.

    - by Monomer
    The Problem: A large static list of strings is provided. A pattern string comprised of data and wildcard elements (* and ?). The idea is to return all the strings that match the pattern - simple enough. Current Solution: I'm currently using a linear approach of scanning the large list and globbing each entry against the pattern. My Question: Are there any suitable data structures that I can store the large list into such that the search's complexity is less than O(n)? Perhaps something akin to a suffix-trie? I've also considered using bi- and tri-grams in a hashtable, but the logic required in evaluating a match based on a merge of the list of words returned and the pattern is a nightmare, and I'm not convinced its the correct approach.

    Read the article

  • TypeConverter.ConvertFrom String to String

    - by Ken
    I'm using a PropertyGrid to display a property. For one property, I'm displaying strings in a drop-down combobox. The displayed text of the property and the value of the property are both strings, but their text is different. The displayed text is friendly, the value text corresponds to a registry key name. I've created a TypeConverter to convert between the display text and the value text, but the ConvertFrom() method appears to work correctly until I change the combo-box selection. It then sends the 'value' text instead of the display text to use during the conversion. Has anyone else used string-to-string conversion successfully?

    Read the article

  • Dollar ($) sign in password string treated as variable

    - by ncatnow
    Spent some time troubleshooting a problem whereby a PHP/MySQL web application was having problems connecting to the database. The database could be accessed from the shell and phpMyAdmin with the exact same credentials and it didn't make sense. Turns out the password had a $ sign in it: $_DB["password"] = "mypas$word"; The password being sent was "mypas" which is obviously wrong. What's the best way to handle this problem? I escaped the $ with a \ $_DB["password"] = "mypas\$word"; and it worked. I generally use $string = 'test' for strings which is probably how I avoided running into this before. Is this correct behavious? What if this password was stored in a database and PHP pulled it out - would this same problem occur? What am I missing here...

    Read the article

  • C#: access a class property when the property identifier is known as a string

    - by Hans
    Hi, I'm using LINQ to Entities on a database which structure is not known in advance. I use reflection to retrieve the information, and now have a list of strings with all the table names. Because I use LINQ, I also have the datasource encapsulated in a C# class (linqContext), with each table being a property of that class. What I want to achieve is this: Assume one of the strings in the table names list is "Employees". This is known in code, I want to do the following: linqContext.Employees.DoSomethingHere(); Is this possible? I know that if all the propertie were just items in a list, I could use the string as indexer, linqContext["Employees"]. However, this is not the case :(

    Read the article

  • Solve equation from string to result in C

    - by Alexandre Cassagne
    Hi, I would like to know if anyone has info or experience on how to do something which sounds simple but doesn't look like it when trying to program it. The idea is : give a string containing an equation, such as : "2*x = 10" for example (this is simple, but it could get very complex, such as sqrt(54)*35=x^2; and so on....) and the program would return x = 5 and possibly give a log of how he got there. Is this doable ? If so, does anyone have a lead ? For info there is this site (http://www.numberempire.com/equationsolver.php) which does the same thing in PHP, but isn't open source. Thanks for any help !

    Read the article

  • WiX: Extracting Binary-string in Custom Action yields string like "???good data"

    - by leiflundgren
    I just found a weird behaviour when attempting to extract a string from the Binary-table in the MSI. I have a file containing "Hello world", the data I get is "???Hello world". (Literary question mark.) Is this as intended? Will it always be exactly 3 characters in the beginning? Regards Leif Sample code: [CustomAction] public static ActionResult CustomAction2(Session session) { View v = session.Database.OpenView("SELECT `Name`,`Data` FROM `Binary`"); v.Execute(); Record r = v.Fetch(); int datalen = r.GetDataSize("Data"); System.IO.Stream strm = r.GetStream("Data"); byte[] rawData = new byte[datalen]; int res = strm.Read(rawData, 0, datalen); strm.Close(); String s = System.Text.Encoding.ASCII.GetString(rawData); // s == "???Hello World" return ActionResult.Success; }

    Read the article

  • Javascript Hex String to Image

    - by Gunnar Hoffman
    Hello everyone. I'll cut right to the chase. Right now I am developing a web based application. It has a PHP REST based architecture that serves up XML documents. On many of these documents attributes are hex encoded picture strings. On the client side jQuery AJAX fetches an XML document with a picture in it. I need to display said picture in some <img> tags. However my knowledge on such methods is lacking so here I am asking for help. Goal: JavaScript String variable in hex or base64 HTML displayed image. Cross browser is required, or a hack for the ones that do not support it is fine. Thanks, Gunnar

    Read the article

  • trim last "," delimiter of a string in vb.net

    - by gerfe
    this is my code - With ad.Tables(2) For i As Integer = 0 To .Rows.Count - 1 If .Rows(i)("name") & "" <> "" Then temp &= .Rows(i)("name") & ", " End If Next End With temp = temp.Trim(",") testing &= "&Name=" & temp & vbCrLf with this is get a comma in the end of the string. but if i do this temp = temp.Trim.Trim(",") all commas are deleted. How do i keep all commas and only delete the last one?

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >