As part of learning C, I wrote the following code to combine directory name with file name. Eg: combine("/home/user", "filename") will result in /home/user/filename. This function is expected work across platforms (atleast on all popular linux distributions and windows 32 and 64bit).
Here is the code.
const char* combine(const char* p...
It's too hot & I'm probably being retarded.
>>> "/1/2/3/".split("/")
['', '1', '2', '3','']
Whats with the empty elements at the start and end?
Edit: Thanks all, im putting this down to heat induced brain failure. The docs aren't quite the clearest though, from http://docs.python.org/library/stdtypes.html
"Return a list of the words...
I will have a string like this:
Bob is a boy. Bob is 1000 years old! <b>Bob loves you!</b> Do you love bob?
I want to parse it into an array, using the following delimiters to identify each array element:
.
!
?
<b> and </b>
So I will have an array with the following structure:
[0]Bob is a boy.
[1]Bob is 1000 years old!
[2]Bob love...
I have a moderately well-formatted HTML document. It is not XHTML so it's not valid XML. Given a offset of the opening tag I need to obtain contents of this tag, considering that it can have multiple nested tags inside of it.
What is the easiest way to solve this problem with a minimum amount of C# code that doesn't involve using non-...
I have a string such as the following:
Are you looking for a quality real estate company?
<s>Josh's real estate firm specializes in helping people find homes from
[city][State].</s>
<s>Josh's real estate company is a boutique real estate firm serving clients
locally.</s>
In [city][state] I am sure you know how difficult ...
I have built a blog platform in VB.NET where the audience are very young, and for some reason like to express their commitment by repeating sequences of characters in their comments.
Examples:
Hi!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3
LOLOLOLOLOLOLOLOLOLOLOLOLLOLOLOLOLO...
I'm trying to compare data from two sources.
ORIG Kick-Ass: Music From The Motion Picture
ALT Kick-A*s (Music from the Motion Picture)
ALT Kick-Ass: (Music from the Motion Picture)[Explicit]
ALT Kick-Ass: A dedication
ALT 1 ALT 2 and ORIG are the same match. ALT 3 is a dummy result.
I need to verify that these have a match, is there ...
Using mysql
I want to display two rows values in to single value
ID Name
---------
01 Raja
02 Ravi
Expected output:
01Raja
02Ravi
How to make a query for this condition?
...
I have to split the file content based on first occurrence of \r\n\r\n
I need flexibility such a way that the lines can just ends with \r\n\r\n or \n\n.
How to split the text?
Example added:
\===================FILE BEGIN==========================================
name: about
title: About
publish: True
order: -1
\r\n
\r\n
examp...
How do I write a function in C++ that takes a string s and an integer n as input and gives at output a string that has spaces placed every n characters in s?
For example, if the input is s = "abcdefgh" and n = 3 then the output should be "abc def gh"
EDIT:
I could have used loops for this but I am looking for concise and an idiomatic ...
i want to remove all text except the text in it <> from textbox
use
c#,dot net
...
Is it possible using a batch script to change string in a txt file?
For example, I have status.txt, which contains 2 lines:
SingleSite integer1
MultiSite integer2
I want to change them into:
TAG integer1
Engineer integer2
so SingleSite becomes TAG and MultiSite becomes Engineer
...
I tried this:
echo preg_replace('/[^,,$]/', '', ',test,hi,');
But gets:
,,,
...
I'm working on a python project in 2.6 that also has future support for python 3 being worked in. Specifically I'm working on a digest-md5 algorithm.
In python 2.6 without running this import:
from __future__ import unicode_literals
I am able to write a piece of code such as this:
a1 = hashlib.md5("%s:%s:%s" % (self.username, s...
Is there a default/easy way in Java for split strings, but taking care of quotation marks or other symbols?
For example, given this text:
There's "a man" that live next door 'in my neighborhood', "and he gets me down..."
Obtain:
There's
a man
that
live
next
door
in my neighborhood
and he gets me down
...
Sorry, my C/C++ is not that good, but the following existing code looks like garbage even to me. It also has a bug - fails when str = "07/02/2010" terminated by '\0' - . I think that instead of fixing a bug, it might as well be rewritten. In Python it is just 'kas\nhjkfh kjsdjkasf'.split(). I know this is C-ish code, but it cannot be tha...
Hi,
How to make a java class immutable and what is the need of immutability and is there any advantage over this?
...
preg_match_all("/[^A-Za-z0-9]/",$new_password,$out);
The above only checks the 1st character, how to check whether all are alpha-numeric?
...
Suppose there are two strings:
$1 off delicious ham.
$1 off delicious $5 ham.
In Python, can I have a regex that matches when there is only one $ in the string? I.e., I want the RE to match on the first phrase, but not on the second. I tried something like:
re.search(r"\$[0-9]+.*!(\$)","$1 off delicious $5 ham.")
..saying "Match ...
I'm calling a Win32 API function and getting back a string padded with null characters. Trim$() doesn't remove them. Is there an easier solution then removing them one character at a time?
...