I'm using
sed -e "s/\*DIVIDER\*/$DIVIDER/g" to replace *DIVIDER* with a user-specified string, which is stored in $DIVIDER. The problem is that I want them to be able to specify escape characters as their divider, like \n or \t. When I try this, I just end up with the letter n or t, or so on.
Does anyone have any ideas on how to do this...
Possible Duplicate:
How to Truncate a string in PHP to the word closest to a certain number of characters?
How can I shorten a string to a maximum of 140 chars without slicing through a word.
Take the following string:
$string = "This is an example string that contains more than 140 characters. If I use PHPs substring functi...
I want to output a header line in a log file and then a line of '-' before the data. To do this I create a string of the header and then outpout the same number of '-'.
But the below code always fails with a CONSTRAINT_ERROR because the generated string is not 1024 characters. In Ada string assignments require exactly the same length no...
I'm trying to figure out how to replace a quote like ' with something like \'.
How would I do this?
I have tried
"'".gsub("'","\\'")
but it just gives an empty string. What am I doing wrong here?
...
Hello !
I have two strings:
$a = '/srv/http/projects/name';
$b = '/projects/name/some/dir';
And I would like to get a merged string with not repeated common part:
$c = '/srv/http/projects/name/some/dir';
Is there any effective way to get it ?
...
How would you convert an array of booleans to a string like "false, true, true, false" - using as few lines of code as possible?
Python allows me to use the following (very nice and clean):
", ".join(map(str, [False, True, True, False]))
In C#, string.Join only allows me to join an array of strings.
So what is a short way to do the...
I just noticed that I can do the following, which came as a complete surprise to me:
Console.WriteLine("{0}:{1}:{2}", "foo", "bar", "baz");
This works for the Write method too. What other methods have signatures supporting this, without requiring the use of String.Format?
Debug.WriteLine doesn't...
HttpResponse.WriteLine doesn't...
...
Possible Duplicates:
C++: How to split a string?
Splitting a string
What is the best way to go about splitting a string up by whitespace in c++?
I'd like to be able to split it based on tab, space, etc. and of course ignore multiple tabs/spaces/etc. in a row as well as not have issues with having those things at the end.
U...
hi,
i get this response from the server:
OK: 0; Sent queued message ID: e3674786a1c5f7a1 SMSGlobalMsgID:6162865783958235 OK: 0; Sent queued message ID: 9589936487b8d0a1 SMSGlobalMsgID:6141138716371692
and so on...
This is just one long string with NO carriage return i copied it exactly as received.
please note, initial OK can be a...
I'd like to use PCRE to take a list of URI's and distill it.
Start:
http://abcd.tld/products/widget1
http://abcd.tld/products/widget2
http://abcd.tld/products/review
http://1234.tld/
Finish:
http://abcd.tld/products/widget1
http://1234.tld/
Any ideas, dear members of StackOverflow?
...
What is the quickest way to find the first character which only appears once in a string?
...
hi, I have two arrays that need to be merged together and trying to figure out the correct way of doing it.
this is the first array
Array
(
[IndividualOutmsg] => Array
(
[0] => Array
(
[user_id] => 3
[number] => 414566765
...
How-to strip email and phone numbers from html input ?
Before: "please contact me at [email protected] or email[at]email.com or by phone at 555 555 555"
After: "please contact me at [Replacement] or [Replacement] or by phone at [Replacement]"
...
I have some XML like this:
<topics>
<topic id="50"/>
<topic id="51"/>
<topic id="52"/>
</topics>
<discussions>
<discussion type="foo">talked about T50 as Discussion 1000</discussion>
<discussion type="bar">Food is yummy!</discussion>
<discussion type="foo">talked about T52 as Discussion 1050</discussion>
</discussions>
Gi...
I'm parsing a xml file and inserting it into database.
However since some text containes double or single quotation I'm having problem with insertion. Currently I'm using the code shown below. But it seems it's inefficient.
s = s.replace('"', ' ')
s = s.replace("'", ' ')
Is there any way I can insert text without replacing these quota...
How do I check if a string is a substring of another string in C without using the substr function?
...
I have the following query:
SELECT
CAST([Action] AS NVARCHAR(4000)) AS CastAction,
CHARINDEX(CAST([Action] AS NVARCHAR(4000)), N'StatusChange') AS FoundIndex
FROM AuditTrail
WHERE action LIKE '%StatusChange%'
Action is an NTEXT field - this query returns many rows, matching StatusChange in the action text, but the charindex r...
I'm trying to use istringstream to recreate an encoded wstring from some memory. The memory is laid out as follows:
1 byte to indicate the start of the wstring encoding. Arbitrarily this is '!'.
n bytes to store the character length of the string in text format, e.g. 0x31, 0x32, 0x33 would be "123", i.e. a 123-character string
1 byte s...
I have a chunk of text like:
<b>First content</b> followed by <b>second content</b>
OR
"First content" and then "second content"
And I want to create an array that looks:
[1] => "First content"
[2] => "second content"
From either example, where I get the content between two tags. I've figured out how to get the first instances, bu...
Using C#, what's the most efficient way to accomplish this?
string one = "(999) 999-9999";
string two = "2221239876";
// combine these into result
result = "(222) 123-9876"
String one will always have 9's.
I'm thinking some kind of foreach on string one and when it sees a 9, replace it with the next character in string two. Not qui...