string-manipulation

Parse items from text file

I have a text file that includes data inside {[]} tags. What would be the suggested way to parse that data so I can just use the data inside the tags? Example text file would look like this: 'this is a bunch of text that is not {[really]} useful in any {[way]}. I need to {[get]} some items {[from]} it.' I would like to end up with '...

Strings in ASP?

Hi All, I have some APSX code that I am trying to modify for a programmer that is out on medicaly leave. I am not an ASP guy, but rather C++ So what I want to do is delare a string, check the first 4 characters and if it is 'http' do something, if not, something else. Here is what I have: string strYT= Left(objFile, 4); if (strYT==...

String Manipulation: Spliting Delimitted Data

I need to split some info from a asterisk delimitted data. Data Format: NAME*ADRESS LINE1*ADDRESS LINE2 Rules: 1. Name should be always present 2. Address Line 1 and 2 might not be 3. There should be always three asterisks. Samples: MR JONES A ORTEGA*ADDRESS 1*ADDRESS2* Name: MR JONES A ORTEGA Address Line1: ADDRESS 1 Address Li...

How to modify characters in a string in Java?

Let's say we have string t. Why does the following not work: for (int i = 0; i < t.length; t++) { t.charAt(i)+=3; } ...

C#: Loop through substring patterns in a string

my pattern is the following: {(code)} where code is a number (up to 6 digits), or 2 letter followed by a number. For example: {(45367)} {(265367)} {(EF127012)} I want to find all occurrences in a long string, I can't just use pure regex , because I need to preform some action when i find a match (like logging the position ...

Regex: Strip non alpha numeric or punctuation.

How can I use PHP to strip out all characters that are NOT alpha, numeric, space, or puncutation? I've tried the following, but it strip punctuation. preg_replace("/[^a-zA-Z0-9\s]/", "", $str); ...

SQL Server: problem with string concatenation.

I'm trying this as part of a big query: (CONVERT(varchar(20), AZ_DTA_APP_AGE, 103) + ' ' + (CONVERT(varchar(20), AZ_DTA_APP_AGE, 108)) AS AZ_DTA_APP_AGE Why it doesn't work? I get: Syntax error near keyword 'AS' ...

How slow is Python's string concatenation vs. str.join?

As a result of the comments in my answer on this thread, I wanted to know what the speed difference is between the += operator and ''.join() So what is the speed comparison between the two? ...

How to format output using MATLAB's num2str

I'm trying to ouput an array of numbers as a string in MATLAB. I know this is easily done using num2str, but I wanted commas followed by a space to separate the numbers, not tabs. The array elements will at most have resolution to the tenths place, but most of them will be integers. Is there a way to format output so that unnecessary tra...

Help! Obj-C/Iphone programming: extracting string from html text and reading off line by line

hihi, I have this html text response from a particular website: <tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="crsdsdfs2221.jpg">crash-2221.jpg</a></td><td align="right">14-Jun-2010 14:29 Notice for every line, there is this href=".__", which is an image file with random name and random format. I wo...

How to split this string and identify first sentence after last '*'?

I'm getting a string similar to the following back from the database: The object of the following is to do: * blah 1 * blah 2 * blah 3 * blah 4. Some more extremely uninteresting text. Followed by yet another sentence full of extremely uninteresting text. Thankfully this is the last sentence. I need to format this so that each * repr...

Split string data into array based on new line and then double digit number

What I'm looking to do is split data from string into an array. Here's the general idea of the text format... xxxxx denotes any mix of alpha-numeric-whitespace data. xxxxx 1 xxxxxxxxxx 2 xxxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxx 3 xxxxxxxxxx 4 xxxxxxxxxx xxxxxxxxxx 5 xxxxxxxxxx (When numbers get into the double digits, the ten's ...

sed variable replacement

I have tried this countless ways, time to throw in the towel and ask the master... #!/bin/bash # Read in the VERSION.header file, this is a plain text file # with returns, which in some of my tests, I am loosing the returns and getting # one string wrapped only by the shell width VERSION_HEADER=`cat VERSION.header` sed 's/_VERSION_HEA...

Remove trailing tags from a HTML textfield in PHP and/or TinyMCE

Hi there I have a problem: I am using TinyMCE for a text field. It all works fine until a user hits the enter button some times at the end of his input (new lines that are not needed). So for some inputs I save <p>CONTENT</p><p> </p><p> </p> or <p>CONTENT</p><br /><br /> Since this input is displayed at other places of the webpag...

USD Currency Formatting in Java

In java, how can I efficiently convert floats like 1234.56 and similar BigDecimals into Strings like $1,234.56 I'm looking for the following: String 12345.67 becomes String $12,345.67 Float and BigDecimal as well. Thanks. ...

Basics of Strings

Ok, i've always kind of known that computers treat strings as a series of numbers under the covers, but i never really looked at the details of how it works. What sort of magic is going on in the average compiler/processor when we do, for instance, the following? string myString = "foo"; myString += "bar"; print(myString) //replace with...

Many things to do on string in php

Hey guys, i am making one website. In that, their is one section in which i have to do some manipulation on some string, and that string data will come from the database. The things which i wanted on my string. First to check How many "<br>" tag character means how many line breaker are their in that string?" In between that tags[<br...

Delphi: is there an RTL function to remove the accents from a string?

I need to remove accents from strings, is there a Delphi (2009+) function for this? I want that my string contains only A-Z a-z 0-9 chars, so I want to remove accents automatically Like: RemoveAccents(àèÃÜÿñ) that gives aeAUyn etc.... ...

python How can I strip first and last double quotes

Hello, I want to strip double quotes from string = '"" " " ""\\1" " "" ""' to become string = '" " " ""\\1" " "" "' I try to use rstrip, lstrip and strip('[^\"]|[\"$]') but it not work How can I do? sorry for my english. Thank for help me. ...

Easiest way to pass modifyable System.String as modifyable LPTSTR ?

BOOL PathFindOnPath( LPTSTR pszFile, LPCTSTR *ppszOtherDirs ); I am calling this API from managed C++. My pszFile is in a System.String. What is the easiest way to pass this as LPTSTR? (Considering its an inout parameter) I have tried pin_ptr and interior_ptr but neither seems to be accepted by the compiler. ...