string

How do you cut off text after a certain amount of characters in PHP?

I have two string that i want to limit to lets say the first 25 characters for example. Is there a way to cut off text after the 25th character and add a ... to the end of the string? So '12345678901234567890abcdefg' would turn into '12345678901234567890abcde...' where 'fg' is cut off. ...

Building string base for Django application

I am building an application in django, that is already using a lot of hardcoded strings. They are mostly in templates, but some also in js files and a few can be found inside the code. Now every time some string needs to be changed people comes to us and we have to waste our time finding it and changing. How could I start with cleaning ...

Search for New Line position in VB.NET String Variable using INSTR

I have an application in VB.NET which gets "String" data from the database. This String has data which looks as below: "This is the update: I have an issue with the application" I need only part of the data, that comes after the new line i.e. "I have an issue with the application". For this I am trying to search the position usi...

Check if string contains another string

In T-SQL, how would you check if a string doesn't contain another string? I have an nvarchar which could be "Oranges Apples". I would like to do an update where, for instance, a columm doesn't contain "Apples". How can this be done? ...

convert string to dict using list comprehension in python

I have came across this problem a few times and can't seem to figure out a simple solution. Say I have a string string = "a=0 b=1 c=3" I want to convert that into a dictionary with a, b and c being the key and 0, 1, and 3 being their respective values (converted to int). Obviously I can do this: list = string.split() dic ...

Is there a string-collapse library function in python?

Is there a cross-platform library function that would collapse a multiline string into a single-line string with no repeating spaces? I've come up with some snip below, but I wonder if there is a standard function which I could just import which is perhaps even optimized in C? def collapse(input): import re rn = re.compile(r'(\...

Does string.replaceAll() performance suffer from string immutability?

Lets say I called replaceAll() on a big string that replaced 1,000 matching instances. Does it mean that 1,000 strings were created and reassigned in process because of string immutability? Is there any faster alternatives? ...

How to find the url using the referer and the href in Python?

Suppose I have window_location = 'http://stackoverflow.com/questions/ask' href = '/users/48465/jader-dias' I want to obtain link = 'http://stackoverflow.com/users/48465/jader-dias' How do I do it in Python? It have to work just as it works in the browser ...

VB.NET split string with quotation marks in it

Trying to split a line wherever "," appears (with the quotation marks), The problem is VB.NET uses " to start/end strings, so I tried using .Split(""",""") but that then splits it by " not "," ...

How to sort out numeric strings as numerics?

If you have strings like: "file_0" "file_1" "file_2" "file_3" "file_4" "file_5" "file_6" "file_11" how can you sort them so that "file_11" doesn't come after "file_1", but comes after "file_6", since 11 > 6. Do I have to parse the string and convert it into a number for this? Windows explorer in Win7 sorts files out the way I wanted...

How to handle strings in VC++?

HI, Once we accept an input from a keyboard, How can we add that character into a string in VC++? Can anyone help me with this? ...

How to add character into a string(using vc++)??

I'm trying to create a text editor in vc++, without using mfc's edit class. I've managed to capture the key pressed using WM_CHAR message, but now how can i add it into a string(or any character handling data type) so that i can display it in my client area using TextOut() or functons similar to it??? ...

Using boost::tokenizer with string delimiters

I've been looking boost::tokenizer, and I've found that the documentation is very thin. Is it possible to make it tokenize a string such as "dolphin--monkey--baboon" and make every word a token, as well as every double dash a token? From the examples I've only seen single character delimiters being allowed. Is the library not advanced en...

Why does string.Format come in several flavors?

.NET provides four very similar versions of String.Format(...) (excluding the one that takes an IFormatProvider argument): Format(String, Object) Replaces one or more format items in a specified string with the string representation of a specified object. Format(String, Object, Object) Replaces the format item in a specified string with...

Java: Converting String to and from ByteBuffer and associated problems

I am using Java NIO for my socket connections, and my protocol is text based, so I need to be able to convert Strings to ByteBuffers before writing them to the SocketChannel, and convert the incoming ByteBuffers back to Strings. Currently, I am using this code: public static Charset charset = Charset.forName("UTF-8"); public static Cha...

PHP: str_replace that only acts on the first match?

I want a version of strreplace() that only replaces the first match in the target string. Is there an easy solution to this, or do I need a hacky solution? ...

Associating Strings with enums in C#

I work on C# window ...vs05 ......i want to put space on enum string ....i do it below code have this.....My problem is after select a value from the combo how can i get the index number of this value .....and if i gone to edit mode then i need to show the value what is user already selected .....how to get enum selected value on basis o...

Why null-terminated strings? Or: null-terminated vs. characters + length storage.

I'm writing a language interpreter in C, and my string type contains a length attribute, like so: struct String { char* characters; size_t length; }; Because of this, I have to spend a lot of time in my interpreter handling this kind of string manually since C doesn't include built-in support for it. I've considered switching...

Good books on string algorithms if any. Do I need a separate book or theme is well explained in general algoritms?

Do I need special book to learn about string algorithms, or it will be enough to pick up a chapter from general books (e.g."Introduction to Algorithms")? I prefer more code and less theory, and language doesn`t matter. It seems to me that many books on algorithms are outdated. Is it true? ...

How can I append data to a std::string in hex format?

I have an existing std::string and an int. I'd like to append the int to the string, but in human readable form (hex notation), rather than in binary gibberish. Normally, I'd just use printf, but I can't do this with a std:: string (can I?) Any suggestions as to how to do this? Example: Given: std::string - "Your Id Number i...