string-manipulation

Split a VARCHAR in DB2 to retrieve a value inside

I have a VARCHAR column that contains 5 informations (2 CHAR(3) and 3 TIMESTAMP) separated with '$'. CREATE TABLE MYTABLE ( COL VARCHAR(256) NOT NULL ); INSERT INTO MYTABLE VALUES ( 'AAA$000$2009-10-10 10:50:00$null$null$null' ), ( 'AAB$020$2007-04-10 10:50:00$null$null$null' ), ( 'AAC$780$null$2007-04-10 10:50:00$2009-...

Weird String.getByte(Encoding) problem

Hello, I am trying this: byte[] b = String.getByte("ASCII") and get an UnsupportedEncodingException Exception String fName = new String(b,"ASCII"); - got the same when used byte[] b = String.getByte("ISO8859_1"); String fName = new String(b,"ISO8859_1"); Appreciate any help. ...

String split question using "*"

Let's say have a string... String myString = "my*big*string*needs*parsing"; All I want is to get an split the string into "my" , "big" , "string", etc. So I try myString.split("*"); returns java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0 * is a special character in regex so I try escaping.... my...

MySQL pattern replace

Would it be possible to do a little more 'advanced' string replacing in a MySQL query? I read about the REPLACE() method, but as far as I know, it cannot be used for fancy stuff. Basically, what I'm trying to do is remove all HTML tags from a specific column in a large dataset. Being able to do this in a single query would be a lot coo...

C# String creation (specified length)

Is there a succinct way (i.e. not a for loop) to create a string of a specified length? Doesn't matter what is in the string. ...

Programmatically extract keywords from domain names

Let's say I have a list of domain names that I would like to analyze. Unless the domain name is hyphenated, I don't see a particularly easy way to "extract" the keywords used in the domain. Yet I see it done on sites such as DomainTools.com, Estibot.com, etc. For example: ilikecheese.com becomes "i like cheese" sanfranciscohotels.com be...

C++ : error: invalid operands of types ‘String*’ and ‘const char [7]’ to binary ‘operator+’

Hi, I'm learning cpp and In my last assignment I am rewriting the std::string class. so here is an outline of my code: string class: class String { public: String(const char* sInput) { string = const_cast<char*> (sInput); } const String operator+(const char* str) { //snip print(); ...

Searching through Collections in Java

I have a java properties file containing a key/value pair of country names and codes. I will load the contents of this file into a Collection like List or HashMap. Then, I want users to be able to search for a country, e.g if they type 'Aus' in a textbox and click submit, then I want to search through the collection I have, containing a...

Highlight whole words, omit HTML

I am writing some C# code to parse RSS feeds and highlight specific whole words in the content, however, I need to only highlight words that are outside HTML. So far I have: string contentToReplace = "This is <a href=\"test.aspx\" alt=\"This is test content\">test</a> content"; string pattern = "\b(this|the|test|content)\b"; string o...

remove last two string char!

The following code: If checkboxList.Items(i).Selected Then .Fields("DESC1").Value += checkboxList.Items(i).Text + ", " End If should produce output such as "A, B, C,(space)", which will then be bound to a dynamically created GridView. I would like to remove the last two-char string, that is ",(space)". How can I do this? ...

How can I create a more user-friendly string.format syntax

I need to create a very long string in a program, and have been using String.Format. The problem I am facing is keeping track of all the numbers when you have more than 8-10 parameters. Is it possible to create some form of overload that will accept a syntax similar to this? String.Format("You are {age} years old and your last name is...

How do I get str.translate to work with Unicode strings?

I have the following code: import string def translate_non_alphanumerics(to_translate, translate_to='_'): not_letters_or_digits = u'!"#%\'()*+,-./:;<=>?@[\]^_`{|}~' translate_table = string.maketrans(not_letters_or_digits, translate_to *len(not_lette...

How do I find out if the first character of a string is a number in VB.NET?

How do I check to see if the first character of a string is a number in VB.NET? I know that the Java way of doing it is: char c = string.charAt(0); isDigit = (c >= '0' && c <= '9'); But I'm unsure as to how to go about it for VB.NET. Thanks in advance for any help. ...

str.split() fails randomly?

this code fails randomly when input comes from specific sources, it works usually OK: var str = input; var lines = str.split("¤"); var map = {}; for(var i = 0; i < lines.length; i++) { var pieces = lines[i].split("="); map[pieces[0]] = pieces[1];} for example this input data does not create MAP at all, there is just one map entry: ...

What does 'string is not terminated' mean?

Hello, Excuse my ignorance, but I don't know what the phrase means. I have a few questions: is there any difference between 'string is not terminated' and 'string is not null terminated'? What is it? How does a non terminated string look like? Thank you! ...

Split String - the Cartesian way.

Given the following string: "foo bar-baz-zzz" I want to split it at the characters " " and "-", preserving their value, but get all combinations of inputs. i want to get a two-dimensional array containing {{"foo", "bar", "baz", "zzz"} ,{"foo bar", "baz", "zzz"} ,{"foo", "bar-baz", "zzz"} ,{"foo bar-baz", "zzz"} ,{"foo", "bar", "baz-z...

String.ToCharArray() stored in StringCollection conversion to numbers and back in VB.net

I have a string which was converted to a char array and stored in a stringcollection, how do I return the numerical value for the character in each string? How can I reverse this process, getting the character from the numerical value? I know I could code a Select Case statement, but that would take a very long time as I need to cover e...

PHP string/word processing question

Lets say I have the following sentence: A quick brown fox jumped over a lazy dog. However I have a limit, that only 25 characters can be allowed in that sentence. This might leave me with something like: A quick brown fox jum However, that sentence doesn't make any grammatical sense, so I would prefer to find the last word which we...

Backticking MySQL Entities

I've the following method which allows me to protect MySQL entities: public function Tick($string) { $string = explode('.', str_replace('`', '', $string)); foreach ($string as $key => $value) { if ($value != '*') { $string[$key] = '`' . trim($value) . '`'; } } return implode('.', $string); } ...

How to get Last Index Of "%" in a string ?

How to get Last Index Of "%" in a string in .NET ? I tried string subString = content.Substring(0, startIndex); int nextOpeningComment = subString.LastIndexOf("%", 0); This is always giving me -1. Here subString I'm getting is: <div id=\"xyz\"> \r\n <img alt=\"\" src=\"App_Themes/Default/Images/abc.jpg\" />\r\n <%-- Any h...