string-manipulation

How to check for valid Date in yyyyMM format

I have an internal business process that my finance dept runs. To kick it off they input a Date in the format of yyyyMM or 201009. I want to check for a valid date from that string but so far I got nothing. I am currently exploring breaking the string up, taking the first 4 and checking that they are between 1990 and 2050(as example) ...

string manipulation in JavaScript

(27.19, 78.01) i have this information in javascript and need in this form. 27.19N , 78.00E if 27.19 is positive then include N after them otherwise S then it can be 27.19S if 78.01 is positive then include E after them otherwise W then it can be 78.01W how i can do this in javascript. ...

Tagging similar sentences with lower time complexity than n^2

Hey All This is my first post, have been a lurker for a long time, so will try my best to explain myself here. I have been using lowest common substring method along with basic word match and substring match(regexp) for clustering similar stories on the net. But the problem is its time complexity is n^2 (I compare each title to all the...

Jquery: Move the focus of an <a> tag from a single word to the entire text <div>

Would appreciate any pointers regarding which function to use for this: Say I have something like this: <div class="myTweet">Check out this awesome link <a href="http://bit.ly/uglylookinglink&gt;http://bit.ly/uglylookinglink&lt;/a&gt;&lt;/div&gt; Which reads: Check out my awesome link http://bit.ly/uglylookinglink All I want to do ...

PHP solution to sanitize user formatted input and make XHTML Strict compliant

What are best solutions for making user formatted input safe + script/flash free XHTML Strict compliant Tidy converts HTML to XHTML Strict. Any similar/alternative options that does this plus sanitizes and removes embedded scripts and flash? ...

How do I concatenate two strings and store them into the same struct key

I'm using Coldfusion. I want to concatenate two strings into the same struct key, but I keep getting an error of "can't convert x into a boolean." For example: <cfset myStruct.string1 = nodes[1].string1.XmlText> <cfset mystruct.string2 = nodes[1].string2.XmlText> Neither of the following works <cfset myStruct.concatendatedSring = n...

The most efficient way to remove all characters in the 1st string from the 2nd string?

I was asked about this question. I can only think of a O(nm) algorithm if n is the length of the 1st string and m is the length of the 2nd string. ...

One regular expression to rule them all (efficiently)?

Hey guys, I've been trying to parse through HTML files to scrape text from them, and every so often, I get some really weird characters like à€œ. I determined that its the "smart quotes" or curly punctuation that is causing the all of my problems, so my temporary fix has been to search for and replace all of these characters with their c...

How to split a string and find the occurence of one string in another?

I need to figure out how to do some C# code in php, and im not sure exactly how. so first off i need the Split function, im going to have a string like "identifier 82asdjka271akshjd18ajjd" and i need to split the identifier word from the rest. so in C#, i used string.Split(new char{' '}); or something like that (working off the to...

sort alphanumeric string, then alternate numeric/alphabet char output

Given an input string (such as D4C3B2A1) I want to sort the alphabet characters, and the numbers (ascending) then alternate them. Expected output would be: A1B2C3D4 The way I thought about doing this was using RegEx to pull out two strings, letters only, then numbers only. Sorting both strings, then using substring to pull out each let...

Python: How exactly can you take a string, split it, reverse it and join it back together again?

How exactly can you take a string, split it, reverse it and join it back together again without the brackets, commas, etc. using python? ...

Importing a TXT file to a DataTable so it matches how Excel imports it - C# .NET

I have a txt file, and I can import it into Excel with the following settings perfectly: Type: Delimited Delimiters: TAB Text Qualifier: None I tried loading it into a DataTable by reading the input file into a String[] array, and then splitting that String[] array. However how do you represent a TAB when splitting a string? Is this...

MYSQL How to use trim in select query

my table have set of records around 50, in the table i have column called USERNAME , but some of username leading and trailing have the white space , so am not getting exact order result because of white space, So tell me how to use the trim in SELECT query , Thanks ...

Testing empty string equality in Objective-C

Hi, I have the following loop which builds an array from characters in a string (the additional @ is there deliberately) NSString *testString = @"@the quick brown fox jumps over the lazy dog"; NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[testString length]]; for (int i=0; i < [testString length]; i++) { ...

In Scala 2.8, how to access a substring by its length and starting index?

I've got date and time in separate fields, in yyyyMMdd and HHmmss formats respectively. To parse them I think to construct a yyyy-MM-ddTHH:mm:ss string and feed this to joda-time constructor. So I am looking to get 1-st 4 digits, then 2 digits starting from the index 5, etc. How to achieve this? List.fromString(String) (which I found her...

C# String Array Replace Last Element

Hi, i have a String Array which comes from a splitted String string[] newName= oldName.Split('\\'); newName.Last().Replace(newName.Last(), handover); Why doesnt this replaces my last element in the Array? last() comes from using linq regards ...

Does a .NET function exist that lets you pass in a string containing Regular Expressions and then return the possible matches?

Before I look into doing this myself, is there already a function out there that will do this: I want to pass in a string containing text and RegEx markup and then it returns all possible matches it would look for in a string. so the following passed to the method abc|def|xyz Would return 3 strings in an array or collection: abc d...

C# Get exact string formation from 'double' type.

Hi All, As I'm working on C#, I have one field named 'Amount'. double amount = 10.0; So, I want the result like '10.0' after converting it to string. If my value amount = 10.00, then I want result '10.00' after converting it to string. So, Basically I want exact result in string as it is in double type. (With precisions). Thanks...

How to efficiently filter a string against a long list of words in Python/Django?

Stackoverflow implemented its "Related Questions" feature by taking the title of the current question being asked and removing from it the 10,000 most common English words according to Google. The remaining words are then submitted as a fulltext search to find related questions. I want to do something similar in my Django site. What is ...

Replace non-numeric characters

I need to replace non-numeric chars from a string. For example, "8-4545-225-144" needs to be "84545225144"; "$334fdf890==-" must be "334890". How can I do this? ...