If you can help with this you're a genius.
Basically, I will have some text like this:
<parent wealthy>
<parent>
<children female>
<child>
jessica
<hobbies>
basketball, soccer, video games
</hobbies>
</child>
<child>
jane
<hobbies>
...
How can I replace all line breaks from a string in Java in such a way that will work on Windows and Linux (ie no OS specific problems of carriage return/line feed/new line etc.)?
I've tried (note readFileAsString is a function that reads a text file into a String):
String text = readFileAsString("textfile.txt");
text = text.r...
I am writing my own string copy function. The following works:
char *src, *dest;
src = (char *) malloc(BUFFSIZE);
//Do something to fill the src
dest = (char *) malloc(strlen(src) + 1);
mystringcpy(src, dest);
void mystringcopy(char *src, char *dest) {
for(; (*dest = *src) != '\0'; ++src, +dest);
}
But this doesn't work:
char *sr...
Hi,
I am working on this PHP function. The idea is to wrap certain words occuring in a string into certain tags (both, words and tags, given in an array). It works OK!, but when those words occur into a linked text or its 'src' attribute, then of course the link is broken and stuffed with tags, or tags that should not be inside a link ar...
Hi, I'm trying to create a list from arguments I receive in a url.
e.g I have:
user.com/?users=0,1,2
Now when I receive it in the request it comes as a string. I want to make a list out of "0,1,2" [0,1,2]
...
def format_title(title):
''.join(map(lambda x: x if (x.isupper() or x.islower()) else '_', title.strip()))
Anything faster?
...
Suppose I have an array of size 10 characters (memset to 0), which I am passing to strncat as destination, and in source I am passing a string which is say 20 characters in length (null terminated), now should I pass the 'count' as 10 or 9?
The doubt is, does strncpy considers the 'count' as size of destination buffer or does it just co...
Hey, I'm just wondering how I could remove all the text if it encounters a certain string inside a string :
EX: 24 Season 1 Episode 3
I would like, that if it find the text Season that it removes it and everything after so it would just leave you with :
24
Thanks
Ah sorry I forgot to say I need this in PHP.
...
Hi,
my question is about how to use bitwise operators on C++ std::string... through overloading or as function does not matter
Example for an working XOR/^ function for std::string:
std::string XOR(std::string value, std::string key)
{
std::string retval(value);
long unsigned int klen = key.length();
long unsigned int vlen = val...
with "basic" is meant: Only the operators "+" (->following..) and "|" (->or) are needed.
Prototype:
preg_match_all(std::string pattern, std::string subject, std::vector<std::string> &matches)
Usage Example:
std::vector<std::string> matches;
std::string pattern, subject;
subject = "Some text with a lots of foo foo and " + char(255) ...
I have a string from which I have to remove following char: '\r', '\n', and '\t'.
I have tried three different ways of removing these char and benchmarked them so I can get the fastest solution.
Following are the methods and there execution time when I ran them 1000000 times:
It should be fastest solution if I have 1 or 2 char to remov...
Hi Guys,
I need to setup a function to remove the first character of a string but only if it is a comma (, - Ive found the substr function but this will remove anything reagrdless of what it is.
I thinking some regex might be involved and i had a look but i cannot work it out
My current code is
text.value = newvalue.substr(1);
T...
I have this code:
function ShowFileExtension($filepath)
{
preg_match('/[^?]*/', $filepath, $matches);
$string = $matches[0];
$pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE);
if(count($pattern) > 1)
{
$filenamepart = $pattern[count($pattern)-1][0];
preg_match('/[^?]*/', $fil...
I have a procedure that concatenates TEXT fields inside another text field. Table A.TextField is composed of the concatenation of Table B.TextField1 + VARCHAR(8000) + B.TextField2 data.
I get the TEXTPTR for the TextField1 and TextField2 and what I do is just to UPDATETEXT 3 times the A.TextField.
At the end of the operation, I´m losin...
hopefully someone can help me.
i want to get a thumbnail id value when an onclick event happens, but no luck, any ideas? thanks
<a href="test.ca/images/image-1.jpg?id=1"; onclick="swap(this); getVa(); return false;">this is a small thumbnail image</a>
Here is the js for swapping the thumbnail:
function swap(image) {
document.g...
I know this is the basic.
I'm just wondering what is the elegant way to do it.
For example:
I want the the 'python01.wav' and 'py*thon' strings from this list
The list is like this:
[
[('name', 'entry')],
[('class', 'entry')],
[('type', 'text/javascript'), ('src', '/term_added.php?hw=python')],
[('type', 'text/javascript')],
[('clas...
Hello,
I have a string which has a version number. I want to read the version number from this code so I can compare it with other code I am using. I have code done below but cannot get it working, can anyone see the problem?
print results
r = re.compile(r'(version\s*\s*)(\S+)')
for l in results:
m1 = r.match(l)
...
Guys,
could you please advice how to verify in python if provided string correspond to provided pattern and return result.
For example the provided pattern is following:
< [prefix]-[id]> separated by ','>|< log >"
where prefix is any number of alphabetic characters,
id is only numbers but not exceeding 5 digits,
log is any number of ...
How to trim a part of a string, and save it in a particular string in MySQL using PHP?
Example:
If a string has the value "REGISTER 11223344 here"
How can I cut "11223344" from the string?
...
I need to create a "obscuring" function which replaces clear-text password in line, before writing it to log.
It looks like this:
function pass_obscure {
my $logline = shift;
my $pass = "wer32pass$"; # this password is an example, the real one is received as parameter, or already stored as global value
$logline =~ ...