My question can be boiled down to, where does the string returned from stringstream.str().c_str() live in memory, and why can't it be assigned to a const char*?
This code example will explain it better than I can
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
stringstream ss("this is a ...
Is it safe to pass raw base64 encoded strings via GET parameters?
...
I'd like a reg exp which can take a block of string, and find the strings matching the format:
<a href="mailto:[email protected]">....</a>
And for all strings which match this format, it will extract out the email address found after the mailto:. Any thoughts?
This is needed for an internal app and not for any spammer purposes!
...
I can't for the life of me figure out how to do this properly. I have a class that needs to store some constants (text that corresponds to values in an enum type) - I have it declared like this (publicly) in my class:
const static char* enumText[];
And I'm trying to initialize it like this:
const char* MyClass::enumText[] = { "A", "...
When inserting a row in mysql database, string values need to be enclosed in quotes where integer don't need to.
Is there any class or library that takes care of this automatically so that I can just pass to a 3rd-party function an array of fieldnames and values and don't have to worry about putting string values in quotes?
Thanks,
...
Hi everyone,
I am trying to replace the backslash (escape) character in a Javascript string literal.
I need to replace it with a double backslash so that I can then do a redirect:
var newpath = 'file:///C:\funstuff\buildtools\viewer.html'.replace(/\\/g,"\\");
window.location = newpath;
However, it seems to have no result.
I don't...
I am working on a WordPress site where one of the pages lists excerpts about corporate clients.
Let's say I have a web page where the visible text looks like this:
"SuperAmazing.com, a subsidiary of Amazing, the leading provider of integrated messaging and collaboration services, today announced the availability of an enhanced version...
Need help , in passing passing C# string to FORTRAN 77 dll as argument.
FORTRAN 77 code:
*$pragma aux CHARIN "CHARIN" export parm(value)
SUBROUTINE CHARIN(FCHAR)
C Declarations
CHARACTER*(*) FCHAR
C
PRINT*,FCHAR
C
RETURN
END
C# code:
using System;
using System.Collections.Generic;
using System.Text;
us...
What is the most efficient way of converting a single column linq query to a string array?
private string[] WordList()
{
DataContext db = new DataContext();
var list = from x in db.Words
orderby x.Word ascending
select new { x.Word };
// return string array here
}
...
Hello
I have string like this:
G:\Projects\TestApp\TestWeb\Files\Upload\file.jpg
How can i do to remove all text before Files (G:\Projects\TestApp\TestWeb)?
The search way before files can change, so i can't count signs and remove after 20 signs.
Thanks for help :)
...
MSDN states that
String.Intern retrieves the system's
reference to the specified String
and
String.IsInterned retrieves a
reference to a specified String.
I think that IsInterned should have returned (I know it doesn't) a bool stating whether the specified string is interned or not. Is that correct thinking ? I mean i...
I'd like to obscure strings at compile time. I know it can be done in other preprocessors but I haven't found a way to do this with the C preprocessor.
...
How to format String in Flex?
Is it possible to do something like this:
var s:String = format("%20d %-10s %s", time, type, message);
In languages like C, C++, C#, Python, Perl there is something similar to my example. But I can't find it for Flex.
I don't want to create special class Formatter for every string that I want to format.
...
Given the following sequence:
"normal %(b)BOLD% normal"
I want to transform this into the following string:
"0000000%(b)bbbb%0000000"
In other words, '%(b)' specifies that all characters up until the next '%' should be 'b'. All other characters should be '0'.
I have tried numerous approaches, including using the RegexKitLite regu...
Hi, I came across these two methods to concatenate strings:
Common part:
char* first= "First";
char* second = "Second";
char* both = malloc(strlen(first) + strlen(second) + 2);
Method 1:
strcpy(both, first);
strcat(both, " ");
strcat(both, second);
Method 2:
sprintf("%s %s", first, second);
In both cases the content of both wou...
How would I make something in cocoa, where the user would type in "open" (space) "www.google.com" and it would open up a page that was directed to google. If the user didn't type open as the first word it would give an error. Also www.google.com could be whatever the user wants it to be. I know it may seem complicated, but it's similar t...
How can I revert back to the default function that python uses if there is no __str__ method?
class A :
def __str__(self) :
return "Something useless"
class B(A) :
def __str__(self) :
return some_magic_base_function(self)
...
match.matches() returns false. This is odd, because if I take this regex and test String to rubular.com, is shows two matches. What am I doing wrong?
Pattern regex = Pattern.compile("FTW(((?!ODP).)+)ODP");
Matcher match = regex.matcher("ZZZMMMJJJOOFTWZMJZMJODPZZZMMMJJJOOOFTWMZJOMZJOMZJOODPZZZMMMJJJOO");
if (match.matches()) {
Syst...
Using the Django framework, I've built a user-based web application. After some time, my client requested that the application disallow creating usernames that contain users' last names.
I have two questions:
Is it possible to do this reliably, always catching someone trying to register a username containing their last name, which is ...
If I have a file, and I want to literally write '42' to it (the value, not the string), which for example is 2a in hex, how do I do it? I want to be able to use something like outfile.write(42) or outfile.write(2a) and not write the string to the file.
(I realize this is a simple question but I can't find the answer of google, probably ...