string-manipulation

Format TimeSpan greater than 24 hour

Hi, Say I convert some second into the TimeSpan object like this. Dim sec= 1254234568 Dim t As TimeSpan = TimeSpan.FromSeconds(sec) How to format TimeSpan object into a format like the following: >105hr 56mn 47sec Is there any built-in function? or I need to write a custom function. Thanks. ...

Edit HTML with returned jQuery html() content

I want to edit some HTML I get from a var I saved. like: var testhtml = $('.agenda-rename').html(); console.log($('input',testhtml).attr('name')); Also tried console.log($(testhtml).find('input').attr('name')); But i get undefined? I figured it'd work like an $.ajax, $.get, $.post? How else can i do it? ...

Include If Else statment in String.Format

Hi, I have the following statemnt. timespan = timespan.FromSeconds(236541) formattedTimeSpan = String.Format("{0} hr {1} mm {2} sec", Math.Truncate(timespan.TotalHours), timespan.Minutes, timespan.Seconds) I have to have it formatted as "hrs mn sec" if there are more than one hour. I want to check this within the String.Format ab...

Why do we need to use String.Empty instead of using "" ?

Possible Duplicate: In C#, should I use string.Empty or String.Empty or ? I got the warning suggesting me to use String.Empty instead of empty string "". I can't figure out why. If you do, please share! ...

How to reduce the length of very long strings?

I have some text which occasionally contains very long strings of characters, which is breaking my CSS. This is an example: http://iapps.smartphonesoft.com/php/software_details.php?id=358281487 whereas this one is fine http://iapps.smartphonesoft.com/php/software_details.php?id=380894729 Is it possible to strip the very long line...

C# String manipulation for Dynamic Query

I have a string it contains can contains either of (1) strQuery = "TempTable.Group_No IN ()"; (2) strQuery = "TempTable.Group_No IN (1,2,3,4,....)"; My task is if it contains "TempTable.Group_No IN ()", (i.e) IN CLAUSE without data i have to replace the string (IN() with IN (NULL)) with "TempTable.Group_No IN (NULL)" How to...

About Microsoft's String Safe Functions.

WCHAR* someString = L"SomeString\n"; WCHAR s1[MAX_PATH]; // I'm sure this is right code. StringCchCopyW(s1, _countof(s1), someString); // But I'm not sure about these example. StringCchCopyW(s1 + 100, _countof(s1) - 100, someString); // Is it right? StringCchCopyW(s1 + 100, _countof(s1), someString); // Is it right? // How about these...

python string conversion for eval.

I have list like: ['name','country_id', 'price','rate','discount', 'qty'] and a string expression like exp = 'qty * price - discount + 100' I want to convert this expression into exp = 'obj.qty * obj.price - obj.discount + 100' as I wanna eval this expression like eval(exp or False, dict(obj=my_obj)) my question is what would b...

error while using mysql_real_escape_string()

my code- require 'database.php'; $title = mysql_real_escape_string($_POST['title']); //line 48 $cat = $_POST['cat']; $txtart = mysql_real_escape_string($_POST['artbody']); //line 50 $date = date("d-m-y"); $q = "INSERT INTO tblarticle (art_title, art_cat, art_des, art_date) VALUES ('$title', '$cat', '$txtart', '$date')"; ERROR--> Wa...

Java String Method

I have comma separated string variable like: String doctors = "doc_vijayan,doc_zubair,doc_Raja" But i want to delete "doc_" from the above String and First Letter should display in capital. I need output like this: String doctors1 = "Vijayan, Zubair, Raja" How to do that? ...

Need help replacing swprintf

I am using some cross platform stuff called nutcracker to go between Windows and Linux, to make a long story short its limited in its support for wide string chars. I have to take the code below and replace what the swprintf is doing and I have no idea how. My experience with low level byte manipulation sucks. Can someone please help me ...

T-Sql query to clean up varchar column

I have a varchar column in one of my tables with data like: 1234abc 1234abcde456757 1234abc Supervisor 1234abc456 Administrator I want to "clean it" by removing any letters and numbers immediately following them so for the above examples I want to have: 1234 1234 1234 Supervisor 1234 Administrator In another word, I want to keep th...

String Division in Python

Hello, I have a list of strings that all follow a format of parts of the name divided by underscores. Here is the format: string="somethingX_somethingY_one_two" What I want to know how to do it extract "one_two" from each string in the list and rebuild the list so that each entry only has "somethingX_somethingY". I know that in C, ther...

jQuery hashing and loading file, string formating?

Hey. I'm loading content dynamically like this: $("#id a").click(function(e){ e.preventDefault(); var hash = this.parentNode.hash; $("#show").load('files/'+ hash +'.html'); $("#show").fadeIn(300); }); But the hash is #first, #second, #third so I have to name files #first.html, #second.html etc. Ho...

Regex pattern match in a character

Hi all, I am new to R so I apologize if this is easy and straight forward. I have successfully read a web page into a character vector. I want to strip this string down to a smaller segment so I can extract some data. So far, so easy. The problem is that I am new to regex and R, so this has been pretty hard for me. I simply want to...

string analysis

IF a string may include several un-necessary elements, e.g., such as @, #, $,%. How to find them and delete them? I know this requires a loop iteration, but I do not know how to represent sth such as @, #, $,%. If you can give me a code example, then I will be really appreciated. ...

Winforms C# change string text order

Hi All- I am new to C# and I get the user's name that is system generated and it comes in the format: LastName, FirstName I want to change this to be added to a database FirstName.LastName I am totally stuck on how to do this, any help would be great, ...

how to keep count of replaced strings

I have a massive string im trying to parse as series of tokens in string form, and i found a problem: because many of the strings are alike, sometimes doing string.replace()will cause previously replaced characters to be replaced again. say i have the string being replaced is 'goto' and it gets replaced by '41' (hex) and gets converted ...

find and replace double newlines with perl?

I'm cleaning up some web pages that for some reason have about 8 line breaks between tags. I wanted to remove most of them, and I tried this perl -pi -w -e "s/\n\n//g" *.html But no luck. For good measure, I tried perl -pi -w -e "s/\n//g" *.html and it did remove all my line breaks. What am I doing wrong? edit I also tried \r\n\r\...

Regular expression to remove the pound sign from a string, if exists

I want to remove the pound sign (#) from a hex string if it exists. I tried the following code... $str = "#F16AD3"; //Match the pound sign in the beginning if (preg_match("/^\#/", $str)) { //If it's there, remove it preg_replace('/^\#/', '', $str); }; print $str; ..but it didn't work. It prints out "#F16AD3". Any ideas? ...