Hi ..
Whatis wrong with this code ?
set<string> nk ;
bitset<3> bs1(string("100"));
nk.insert(bs1.to_string());
error: no matching function for call to `std::bitset<3u::to_string()'
why?!
I am using the following regex:
(public|private +)?function +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)}
To match the following string:
public function messenger(text){
sendMsg(text);
}
private function sendMsg(text){
alert(text);
}
(There is no line breaks inthestring, they are converted to whitespaces before the regex runs)
I wanted it to capture both functions, but it is capturing:
$1: ""
$2: "messenger"
$3: "text"
$4: " sendMsg(text); } private function sendMsg(text){ alert(text); "
By the way, I am using Javascript.
Hi,
Is there a way to query a JSON (String) for a specific item?
ie:
String jSon = "{\"a\":{\"b\":27472483,\"c\":\"123\"}}";
such that:
Int32 bob = (Int32)getFromJSON("a.b", jSon);
// bob == 27472483
Thank you,
-Theo
how to convert a HTML string to a plain text in iphone dev. Is there any in built functions which does it ?
I am actually downloading a html string from web and showing it inthe UIwebview and i am giving the user a edit option so that the html needs to converted to tet so that user can edit
Thanks...
Hi,
I need a regex expression (PCRE) to match a integer number inside a string, being thestring like : image89.jpg
I've tried many options without success.
I'm using preg_replace() by the way
My last attempt :
preg_replace('(\d+)', '$1', 'image89.jpg');
While decoding,I am getting NSData bytes by decoding a string.I am converting NSData bytes as string then I am getting the following out put.
-(void)decodeAction:(NSString*)str
{
NSData *data=[NSData base64DataFromString:str];
NSString *stt=[NSString stringWithFormat:@"%@",data];
printf("\n stt %s",[stt UTF8String]);
}
<4f7c204d 6c204d61 604d6164 61616461 6164616e 24616e20 4d6e204d 6e204d6f 604d6f68 616f6861 6f68616e 28616e
Hello
If I have a method like this:
public static String convertDateTimeToString(DateTime dt) {
return dt.getDate() + " " + dt.getTime();
}
Which takes a Datetime object of my own which contains a Java.sql.date and a Java.sql.time, whatisthe best way of reversing the process so that I can substring a Java.sql.date and a Java.sql.time from a string?
Or if DateTime dt is a JodaTime DateTime object?
If this can be done without reference to Java.util.date.
Thanks
Mr Morgan.
Hello everybody
I am trying to exclude a certain string from a file search.
Suppose I have a list of files: file_Michael.txt, file_Thomas.txt, file_Anne.txt.
I want to be able and write something like
ls *<and not Thomas>.txt
to give me file_Michael.txt and file_Anne.txt, but not file_Thomas.txt.
The reverse is easy:
ls *Thomas.txt
Doing it with a single character is also easy:
ls *[^s].txt
But how to do it with a string?
Sebastian
I have the following:
LPSTR email // Has data in it already
LPSTR index=strchr(email,'@');
Now I want to Insert into a new string:
LPSTR username
the part of "email" from the beginning of thestring to "index".
For example:
email="[email protected]"
so username="roel" .
Is there a function to do it quick or do I need to build one?
Roel
We know that stringis a reference type , so we have
string s="God is great!";
but on the same note if i declare class say Employee which is a reference type so why below piece of code does not work ?
Employee e = "Saurabh";
2- How do we actually determine if a type is a reference type or value type?
Instead of adding each item one by one to the ListBox destinationList from thestring array m_List like this:
foreach (object name in m_List)
{
destinationList.Items.Add((string)name);
}
Is there any better way I can do it?
I don't want to bind the data to the destinationList since I want to delete some entries from the ListBox later on.
HI All,
I've been using the basic split for a while - where I just parse out a string into an array based on a simple token like " " or ",".
So of course a customer tries this: \\.br\ which fails miserably.
I need to parse to an array of lines. Thestring for example looks like this:
"LINE 1\\.br\\LINE 2\\.br\\LINE 3\\.br\\LINE 4\\.br\\"
and this fails with java.util.regex.PatternSyntaxException: Unexpected internal error.
Any ideas?
In my C++ program I want to parse a small piece of XML, insert some nodes, then extract the new XML (preferably as a std::string)
RapidXML (http://rapidxml.sourceforge.net/) has been recommended to me, but I can't see how to retrieve the XML back as a text string.
(I could iterate over the nodes and attributes and build it myself, but surely there's a build in function that I am missing)
Thank you
Hey guys,
I am using heroku for a RoR application and am trying to manually set the length of a string column and am having trouble.
I tried making a migration along the lines of
change_column :posts, :content, :string, :length => 10000
I assumed this would work but no such luck, anyone have some pointers?
Thanks!
I have 2 classes,
public class Account {
private int balance = 50;
public int getBalance() {
return balance;
}
public void withdraw(int amt){
this.balance -= amt;
} }
and
public class DangerousAccount implements Runnable{
private Account acct = new Account();
public static void main(String[] args) throws InterruptedException{
DangerousAccount target = new DangerousAccount();
Thread t1 = new Thread(target);
Thread t2 = new Thread(target);
t1.setName("Ravi");
t2.setName("Prakash");
t1.start();
/* #1 t1.join(); */
t2.start();
}
public void run(){
for(int i=0; i<5; i++){
makeWithdrawl(10);
if(acct.getBalance() < 0)
System.out.println("Account Overdrawn");
}
}
public void makeWithdrawl(int amt){
if(acct.getBalance() >= amt){
System.out.println(Thread.currentThread().getName() + " is going to withdraw");
try{
Thread.sleep(500);
}catch(InterruptedException e){
e.printStackTrace();
}
acct.withdraw(amt);
System.out.println(Thread.currentThread().getName() + " has finished the withdrawl");
}else{
System.out.println("Not Enough Money For " + Thread.currentThread().getName() + " to withdraw");
}
}
}
I tried adding synchronized keyword in makeWithdrawl method
public synchronized void makeWithdrawl(int amt){
and I keep getting this output as many times I try
Ravi is going to withdraw
Ravi has finished the withdrawl
Ravi is going to withdraw
Ravi has finished the withdrawl
Ravi is going to withdraw
Ravi has finished the withdrawl
Ravi is going to withdraw
Ravi has finished the withdrawl
Ravi is going to withdraw
Ravi has finished the withdrawl
Not Enough Money For Prakash to withdraw
Not Enough Money For Prakash to withdraw
Not Enough Money For Prakash to withdraw
Not Enough Money For Prakash to withdraw
Not Enough Money For Prakash to withdraw
This shows that only Thread t1 is working...
If I un-comment the the line saying
t1.join();
I get the same output.
So how does synchronized differ from join() ?
If I don't use synchronize keyword or join() I get various outputs like
Ravi is going to withdraw
Prakash is going to withdraw
Prakash has finished the withdrawl
Ravi has finished the withdrawl
Prakash is going to withdraw
Ravi is going to withdraw
Prakash has finished the withdrawl
Ravi has finished the withdrawl
Prakash is going to withdraw
Ravi is going to withdraw
Prakash has finished the withdrawl
Ravi has finished the withdrawl
Account Overdrawn
Account Overdrawn
Not Enough Money For Ravi to withdraw
Account Overdrawn
Not Enough Money For Prakash to withdraw
Account Overdrawn
Not Enough Money For Ravi to withdraw
Account Overdrawn
Not Enough Money For Prakash to withdraw
Account Overdrawn
So how does the output from synchronized differ from join() ?
Hi everyone,
can I convert a string to a html object?
like:
string s = '<div id="myDiv"></div>';
var htmlObject = s.toHtmlObject;
so that i can later on get it by id and do some changing in its style
var ho = document.getElementById("myDiv").style.marginTop = something;
Thanx a million in advance,
Lina
I have an ASP app that has a string array as such (there are much more than this):
7.5.0.17 Date: 05_03_10
7.5.0.18 Date: 05_03_10
7.5.0.19 Date: 05_04_10
7.5.0.2 Date: 02_19_10
7.5.0.20 Date: 05_06_10
7.5.0.3 Date: 02_26_10
7.5.0.4 Date: 03_02_10
7.5.0.5 Date: 03_08_10
7.5.0.6 Date: 03_12_10
7.5.0.7 Date: 03_19_10
7.5.0.8 Date: 03_25_10
7.5.0.9 Date: 03_26_10
7.5.1.0 Date: 05_06_10
How do I go about sorting these string by version descending?
I am trying to achieve below output using regex but not able to, can someone please correct the regex -
input string :
data-placeholder=""[Refer" to "Conditions To Entry Of The Confirmation Order" and "Conditions To Effective Date" sections]"
output string :
data-placeholder="[Refer to Conditions To Entry Of The Confirmation Order and Conditions To Effective Date sections]"
regex tried
\s*"\s*([^ "]+)"\s*(?=["])
I have an std::string containing a command to be executed with execv, whatisthe best "C++" way to convert it to the "char *argv[]" that is required by the second parameter of execv()?
To clarify:
std::string cmd = "mycommand arg1 arg2";
char *cmd_argv[];
StrToArgv(cmd, cmd_argv); // how do I write this function?
execv(cmd_argv[0], cmd_argv);
Given a string s, whatisthe fastest method to generate a set of all its unique substrings?
Example: for str = "aba" we would get substrs={"a", "b", "ab", "ba", "aba"}.
The naive algorithm would be to traverse the entire string generating substrings in length 1..n in each iteration, yielding an O(n^2) upper bound.
Is a better bound possible?
(this is technically homework, so pointers-only are welcome as well)
ok i have this program working using c-strings. I am wondering if it is possible to read in blocks of unformatted text to a std::string? I toyed arround with if >> but this reads in line by line. I've been breaking my code and banging my head against the wall trying to use std::string, so I thought it was time to enlist the experts. Here's a working program you need to supply a file "a.txt" with some content to make it run.
i tried to fool around with:
in.read (const_cast<char *>(memblock.c_str()), read_size);
but it was acting odd. I had to do std::cout << memblock.c_str() to get it to print. and memblock.clear() did not clear out thestring.
anyway, if you can think of a way to use STL I would greatly appreciate it.
Here's my program using c-strings
// What this program does now: copies a file to a new location byte by byte
// What this program is going to do: get small blocks of a file and encrypt them
#include <fstream>
#include <iostream>
#include <string>
int main (int argc, char * argv[])
{
int read_size = 16;
int infile_size;
std::ifstream in;
std::ofstream out;
char * memblock;
int completed = 0;
memblock = new char [read_size];
in.open ("a.txt", std::ios::in | std::ios::binary | std::ios::ate);
if (in.is_open())
infile_size = in.tellg();
out.open("b.txt", std::ios::out | std::ios::trunc | std::ios::binary);
in.seekg (0, std::ios::beg);// get to beginning of file
while(!in.eof())
{
completed = completed + read_size;
if(completed < infile_size)
{
in.read (memblock, read_size);
out.write (memblock, read_size);
} // end if
else // last run
{
delete[] memblock;
memblock = new char [infile_size % read_size];
in.read (memblock, infile_size % read_size + 1);
out.write (memblock, infile_size % read_size );
} // end else
} // end while
} // main
if you see anything that would make this code better please feel free to let me know.
If I have the following plain string, how do I divide it into an array of three elements?
{["a","English"],["b","US"],["c","Chinese"]}
["a","English"],["b","US"],["c","Chinese"]
This problem is related to JSON string parsing, so I wonder if there is any API to faciliate the conversion.
Hello All-
In C# how can I search through a Folder and its Subfolders to find files that match a string value. My string value could be "ABC123" and a matching file might be ABC123_200522.tif. Can an Array collect these? Thanks in advance.
-Josh
I have to following entity object
@Entity
public class Foobar {
...
private List<String> uuids;
...
}
Now I'd like to make a criteria query which would fetch all Foobar pojos whose uuids list contains thestring "abc123", I'm just not sure how to make the appropriate criterion.
In Java, is there a simple method to convert the format of a given string? For example, I have thestring "test22". I'd like the binary value and hex value. As well as possibly the ascii values of each character?