string-manipulation

Subprocess in Python Add Variables

Subprocess in Python Add Variables import subprocess subprocess.call('Schtasks /create /sc ONCE /tn Work /tr C:\work.exe /st 15:42 /sd 13/10/2010') I want to be able to set the variables on the above command. the variables are the time '15:42' separated in 15 and 42 and the date '13/10/2010' separated in day , month and year any i...

how can i split a string C#

i have a string, something like this: 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890. and i have to split it. the first 8, then the next 4 and so on. Edit: i would prefer to define the length of the pieces in a separate file. and the program to get the length form the e...

Configuring dynamic email content with String replace() or replaceAll()

I am using Spring MVC for my web application and I am using my applicationContext.xml file to configure my emails which I am injecting into my controllers in my spring-servlet.xml file. Some of the emails I need to send will need to be tailored to the customer that they are being sent to. Certain information in the email (First name, La...

How did {0}, {1}, etc become the standard for formatting strings?

Just curious about this in the history of development... how did brackets with the array index ({0}, {1}, and so on) become the standard of string formatting? Any special significance, or something somebody picked out of midair in the 80's? ...

How to read one line of text at a time and write back out to another file in VB6

I have very little experience with VB6 and I need some help. I'm trying to read from file "A" one line at a time, make changes to that line, and write it back out to file "B". Appending File "B" as I go. I've found plenty of info on the web but none of it matches what I'm looking for. If there's anyone who knows of a good link or can s...

preg_replace and date

I want to remove all - and / characters in a date string. Can someone give me a hand? Here is what I have but it doesn't work. preg_replace('/','',$date); preg_replace('-','',$date); Also, is there a way to group these two expressions together so I don't have to have 2 preg_replaces? ...

iphone sdk - Remove all numbers except for characters a-z from a string

In my app I want to remove numbers except characters a-z from string. How can I get only characters? ...

How to get the length of a string containing character references while counting the character references as one single character?

How can I get the length of string that also contains character references? I want to count only the number of characters which will be displayed in the browser. Like $raw = "Stack&#00f9" = Length = 6 $raw = "Stack12345" = Length = 10 $raw = "Stack&#00f9&#00f9" = Length = 7 Thanks in advance ...

PLSql return values

Hiya, Here I go again with some PLSql.. I want to know, if there's anyway I can use the following function like a select without having to turn it into a function or procedure (so I can see the code from the script where it is contained). The code would be like: DECLARE outpt VARCHAR2(1000) := ''; flow_rI VARCHAR2(50); ...

Matching Subset in a String

Let's say I have- String x = "ab"; String y = "xypa"; If I want to see if any subset of x exists in y, what would be the fastest way? Looping is time consuming. In the example above a subset of x is "a" which is found in y. ...

How to efficiently search a string and insert in C#

I need to inject some text into an http response body generated by an ASP.NET MVC ViewResult. I've extended ViewResult and overridden the ExecuteResult Method, and at this point: this.View.Render(viewContext, context.HttpContext.Response.Output); I need to intercept the response output. I know I can do something like: var builder = ...

How do I use rstrip to remove trailing characters?

I am trying to loop through a bunch of documents I have to put each word in a list for that document. I am doing it like this. stoplist is just a list of words that I want to ignore by default. texts = [[word for word in document.lower().split() if word not in stoplist] for document in documents] I am returned with a list of...

Eliminate the letters or marks out only leave numbers and apostrophe

the cases are listed below; 82&? 82,9 abse82,9>dpkg After Regex 82 82,9 82,9 Please help me to do it on c# with using Regex ...

Remove specific characters from a string in python

I'm trying to remove specific characters from a string using python. This is the code i'm using right now. Unfortunately it appears to do nothing to the string?? for char in line: if char in " ?.!/;:": line.replace(char,'') ...

Regex in Python

I have the following string: schema(field1, field2, field3, field4 ... fieldn) I need to transform the string to an object with name attribute as schema and the field names as another attribute which is a list. How do I do this in Python with a regular expression? ...

Manipulating strings in jQuery

Hi folks I've got an anchor tag with a specific URL to which I want to add a class. I'm currently doing this as follows: $('a[href=http://this.ismyurl.com/folder/file.html]').addClass('red'); The problem I have is that this URL is not consistent. The filename, file.html is always the same, so if I could manipulate this string and f...

How do I shuffle the characters in a string in JavaScript?

In particular, I want to make sure to avoid the mistake made in Microsoft's Browser Choice shuffle code. That is, I want to make sure that each letter has an equal probability of ending up in each possible position. e.g. Given "ABCDEFG", return something like "GEFBDCA". ...

str_replace in SQL UPDATE?

Here's a sample table: name | picture John S. | http://servera.host.com/johns.png Linda B. | http://servera.host.com/lindab.png ... Let's say there are several hundred more records. Let's also say we moved servers from "servera" to "serverb". Would it be possible to go into this table with one query to rename the c...

Get a file/directory path from a string that contains other data

Hello, How would I get the directory and filename from the following string using C#: string test = "[email protected], snap555.jpg, c:\users\test\desktop\snap555.jpg"; I only want to be able to get the "c:\users\test\desktop\snap555.jpg" from the string and turn it into another string. The characters before the "," will always be differ...

C++ : Read form text file and convert to int problem?

I have this code that reads from marks.txt file. #include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; int main () { string name,result; int number1; ifstream myfile ("marks.txt"); if (myfile.is_open()) { while ( !myfile.eof() ) { getline (myfile,name,'\t'); getli...