What's the easiest way to parse a string and extract a number and a letter? I have string that can be in the following format (number|letter or letter|number), i.e "10A", "B5", "C10", "1G", etc.
I need to extract the 2 parts, i.e. "10A" -> "10" and "A".
Update: Thanks to everyone for all the excellent answers
...
Hello, I have looked around, but I can't seem to find any examples of this. I am relatively new to C++, and was wondering how I could convert a string to upper case. The examples I have found from googling only have to deal with char's, and not with strings.
...
This problem is a challenging one. Our application allows users to post news on the homepage. That news is input via a rich text editor which allows HTML. On the homepage we want to only display a truncated summary of the news item.
For example, here is the full text we are displaying, including HTML
In an attempt to make a b...
I often find myself doing quick checks like this:
if (! eregi('.php',$fileName))
$filename.='.php';
But sadly eregi() is going to be deprecated in PHP 6, which means all of my code that uses it will be rendered useless :(.
Is there another function that behaves exactly the same way as eregi()? I don't know anything about reg ex...
I have the following string replacement problem and I am in quite a fix here
PFB the sample string
$string = 'The quick sample_text_1 56 quick sample_text_2 78 fox jumped over the lazy dog.';
$patterns[0] = '/quick/';
$patterns[1] = '/quick/';
$patterns[2] = '/fox/';
$replacements[2] = 'bear';
$replacements[1] = 'black';
$replacement...
I have a string in this format:
<!--Start 498-->
some stuff here
<!--End 498-->
<!--Start 498-->
some more stuff here
<!--End 499-->
and so on.
How can I split this string to remove the content between a certain block of <!--Start xx-> and <!--End xx-->?
For example, if I wanted to remove the text between <!--Start 500--> and <...
I'm running into an odd problem with concatenating or printing strings. I have a char * that can be set to one of a few values of string literal.
char *myStrLiteral = NULL;
...
if(blah)
myStrLiteral = "foo";
else if(blahblah)
myStrLiteral = "bar";
And I have some other strings that I get from library functions or that are concate...
If I have some text that I want to print out on a page, but only want to print say the first 100 words before eclipsing it... what's the easiest way to do this?
...
I am now maintaining a legacy VBA/Access 2000 application for a client. They have a customer who emails orders with text that looks like this
Contact: Peggy Hill
Company: Arlen Residential Mortgage Finance Co
Address: 43456 South 18939 West, Suite 47995
City: Arlen City
ContactState: TX
ContactZip: 88888
Phone: 8019990000
Email: peggy....
Sorry, todays silly question (and easy points) but whats the best way to convert a list(of string) to a string with the values seperated by ,
Sorry ....
...
Ok,
I have a string in a sql table like this
hello /r/n this is a test /r/n new line.
When i retrieve this string using c# for a textbox using multiline i expect the escape chars to be newlines.
But they are not and what happens is i get the line exactly as it is above.
It seems that the string returned from the table is taken as l...
Getting a substring of text containing HTML tags
Assume that you want the first 10 characters of the following:
"<p>this is paragraph 1</p>this is paragraph 2</p>"
The output would be:
"<p>this is"
The returned text contains an unclosed P tag. If this is rendered to a page, subsequent content will be affected by the open P tag. Ide...
I'm trying to build a list that will be used as the in clause of a select statement. The requirement is to have the user enter a comma separated list of descriptions. Each description can contain spaces so I can't remove the spaces before splitting by comma to add the single quotes around each description. I want to remove all white s...
A while back a post by Jon Skeet planted the idea in my head of building a CompiledFormatter class, for using in a loop instead of String.Format().
The idea is that the portion of a call to String.Format() spent parsing the format string is overhead. We should be able to improve performance by moving that code outside of the loop. The...
I need to write a function in python that gets a string-
If the first or last characters in the string are spaces, then they should be removed (both). If not than nothing should be done.
" Hello " ----> "Hello"
" Hello" -----> "Hello"
"Hello " -----> "Hello"
"Bob has a cat" ----> "Bob has a cat" (none of the spaces in the middle are...
I have the following SQL script:
DECLARE @temp table (
ID int IDENTITY(1, 1),
data nvarchar(100)
)
INSERT INTO @temp (data) VALUES ('a,b,c')
INSERT INTO @temp (data) VALUES ('d,e,f')
SELECT *
FROM @temp AS T
INNER JOIN
(SELECT *
FROM dbo.__StringSplit(T.data, ',', T.ID)) AS S
ON T.ID = S.RefID
And on ...
This is all asp.net c#.
I have an enum
public enum ControlSelectionType
{
NotApplicable = 1,
SingleSelectRadioButtons = 2,
SingleSelectDropDownList = 3,
MultiSelectCheckBox = 4,
MultiSelectListBox = 5
}
The numerical value of this is stored in my database. I display this value in a datagrid.
<asp:boundcolumn dat...
How do I string manipulation on the output of <xsl:apply-templates>?
I need to escape quotes etc as it's finally being passed to a JavaScript variable.
...
Given a (char *) string, I want to find all occurrence of a substring and replace it with an alternate string. I do not see any simple function that achieves this in <string.h>
...
I have the following string:
FirstName=John&LastName=Doe&City=London&ConfirmationId=WXASL320330
I want to extract the confirmationId from it. I have done a split on it and passed in the & character, but this returns ConfirmationId=WXASL320330 and I just WXASL320330. What is the best way of doing this?
The string is actually part...