string-manipulation

Why is this JavaScript code invalid in Firefox?

I accidentially typed in \s instead of " ", while(cname.charAt(cname.length-1) == "\s") Aren't special characters resolved in all string literals? Also, what is a proper regular expression to cut off all tabs and spaces from EOL? The my /(.*)[\s\t]/ selector just won't work! So I had to fallback to while(if.. substr). ...

How to correctly align tabbed CSV data text files using C#?

I have the following stringBuilder that I am using as part of Log4net log layout. var sb = new StringBuilder(DateTime.Now.ToString(DateFormatString, CultureInfo.InvariantCulture)); sb.Append("\t"); sb.Append(log.EventAction); sb.Append("\t"); sb.Append(log.Id); sb.Append("\t")...

How to delete last character in a string in C#?

Building a string for post request in the following way, var itemsToAdd = sl.SelProds.ToList(); if (sl.SelProds.Count() != 0) { foreach (var item in itemsToAdd) { paramstr = paramstr + string.Format("productID={0}&", item.prodID.ToString()); } } after I get resulting paramstr, I need to delete last ch...

LINQ to SQL on Dynamic Entity Types?

Trying out a new project with Framework 4.0. I have 2 SQL Server tables with matching DBML entities in my project (EntA and EntB). EntA has a Notes property that maps to a VarChar(50) column. EntB has a NoteText property that maps to a Char(100) column. I have some simple Linq-to-SQL code that prepends the text "* Note: " for each e...

T-SQL: How to obtain the the exact length of a string in characters?

I'm generating T-SQL SELECT statements for tables for which I have no data type information up-front. In these statements, I need to perform string manipulation operations that depend on the length of the original value of the tables' columns. One example (but not the only one) is to insert some text at a specific position in a string, ...

Java: Split string when an uppercase letter is found

I think this is an easy question, but I am not able to find a simple solution (say, less than 10 lines of code :) I have a String such as "thisIsMyString" and I need to convert it to a String[] {"this", "Is", "My", "String"}. Please notice the first letter is not uppercase. ...

java decimal separator

Hi mates, Is there a way to configure Java's decimal separators with JVM parameters? I'd know how to do it in code level, but unfortunately this time I cannot touch it. I have now: "1,322.03" and I wish there was some config that would make that look like 1.322,03. Oracle has that NLS_NUMERIC_CHARACTERS, which solve's for me in most c...

Javascript - Replace implementations?

Hi. I have to check a string client side. If it contain only "\" (1, 2, or 1000 time) i need to refuse it. Code (with some of your suggestion that unfortunatly dont work): value.replace(/\\/g, ''); if(value=="") alert("NO"); else alert("YES"); so : value="\" = NO value="\hello \people" = YES value="\\\\hello \\people" = YES value="he...

How can I extract the middle part of a string in FSharp?

I want to extract the middle part of a string using FSharp if it is quoted, similar like this: let middle = match original with | "\"" + mid + "\"" -> mid | all -> all But it doesn't work because of the infix operator + in pattern expression. How can I extract this? ...

Java Equivalent to .NET/C# String.Format

Is there an equivalent to the .NET/C#'s String.Format in Java? ...

Java String manipulation (A/B)+C

Hello, is there any java library in the wild which can "calculate" string: (aaa/bbb/ccc)+ddd into aaa ddd, bbb ddd, ccc ddd and can maybe "solve" nested: (a+(b/c))/((d/e)+f) to a b, a c, d f, e f Thanks ...

Returning all characters before the first underscore

Hello, Using re in Python, I would like to return all of the characters in a string that precede the first appearance of an underscore. In addition, I would like the string that is being returned to be in all uppercase and without any non-alpanumeric characters. For example: AG.av08_binloop_v6 = AGAV08 TL.av1_binloopv2 = TLAV1 I a...

C# Algorithm that Re-arranges Chars in a String

I would like a C# algorithm that re-arranges the chars in a string that is dynamic in length. Having trouble finding one and I know there has to be one out there. The algorithm has to realign elements to form new strings in all possible combinations. For instance, "cat" would produce the following: cat cta tca tac act atc ...

PHP: remove extra space from a string using regex

How do I remove extra spaces at the end of a string using regex (preg_replace)? $string = "some random text with extra spaces at the end "; ...

How to Extract the Word Following a Symbol?

I have a string that could have any sentence in it but somewhere in that string will be the @ symbol, followed by an attached word, sort of like @username you see on some sites. so maybe the string is "hey how are you" or it's "@john hey how are you". IF there's an "@" in the string i want to pull what comes immediately after it into i...

String split not returning empty results

I'm trying to use "value1:value2::value3".split(":"); Problem is that I want it to include the blank results. It returns: [value1, value2, value3] It should be: [value1, value2, , value3] Does anyone know the regexp to fix this? Ok I found cause of problem. I'm actually reading a text file and it contains this line: 123:;~\&:ST0...

how to detect telephone numbers in a text (and replace them) ?

I know it can be done for bad words (checking an array of preset words) but how to detect telephone numbers in a long text? I'm building a website in PHP for a client who needs to avoid people using the description field to put their mobile phone numbers..(see craigslist etc..) beside he's going to need some moderation but i was wonderi...

How can I append a string to an existing field in MySQL?

I want to update the code on all my record to what they currently are plus _standard any ideas? So for example if the codes are apple_1 and apple_2 I need them to be apple_1_standard and apple_2_standard Before: id code ------------ 1 apple_1 1 apple_2 Psuedo Query: update categories set code = code + "_standard" where i...

Return the portion of a string before the first occurrence of a character in php

In PHP, what is the simplest way to return the portion of a string before the first occurrence of a specific character? For example, if I have a string... "The quick brown foxed jumped over the etc etc." ...and I am filtering for a space character (" "), the function would return "The" Thanks! ...

Android: Something better than android:ellipsize="end" to add "..." to truncated long Strings?

This property makes "short and very-long-word" to "short and" . But I want to have smth. like "short and very-lon..." Right now I truncate the String in Java code. However, thats based on the number of characters and not the actual length of the link. So, the result isn't very nice. String title; if(model.getOrg...