QueryCAT Logo
Search 5,000,000+ questions and answers.

Frequently Asked Questions

How can I count the number of occurrences of a substring within a string?

Found in /usr/local/lib/perl5/5.8.8/pod/perlfaq9.pod
There are a number of ways, with varying efficiency. If you want a count of a certain single character (X) within a string, you can use the "tr///" function like so: $string = "ThisXlineXhasXsomeXx'sXinXit"; $count = ($string =~ tr/X//); print "There are $count X characters in the string"; This is fine if you are just looking for a single character.

How do I convert a string to a number?

Updating the For Beginners forum FAQ - GameDev.Net Discussio...
I am including the header file <string>, and I am using the string class, but the code doesn't compile? (namespace resolution, having the std:: topics) How do I use unique() with vectors? (answered only once, but still a good question to have due to people not knowing that it's possible to do) See similar questions...

How do I convert a std::string to a number?

Miscellaneous technical issues, C++ FAQ Lite
There are two easy ways to do this: you can use the <cstdio> facilities or the <iostream> library. In general, you should prefer the <iostream> library. See similar questions...

What is the most efficient way to count the number of bits which are set in a value?

Infrequently Asked Questions in comp.lang.c
Start a counter at zero and add one to it for each bit set. Some operating systems may provide a call to do this. For values over INT_MAX/2, start the counter at CHAR_BIT * sizeof(int) and subtract one for each bit not set. See similar questions...

Can I use SPARQL to search for substring matches within literal values?

SPARQL Protocol and Query Language: SPARQL Frequently Asked ...
SPARQL provides the function, regex(), which can be used to test whether a literal value contains a certain substring: SELECT ?title WHERE { _:book :title ?title . FILTER (regex(?title, "SPARQL")) . } The regex() function expects its first argument to be either a plain literal without a language tag or else a typed literal with a datatype of xsd:string. Plain literals with a language tag or typed literals of other datatypes will evaluate to a type error which causes the filter to fail. See similar questions...

How can I write an efficient number to string routine?

Frequently Asked Questions
Process the number starting from the end (i.e. See similar questions...

How do I split a string?

Frequently Asked Questions for comp.lang.lisp
There is no 'right' answer to this question; many lisp programmers have rolled their own solution in the past, and others are of the view that it should never be necessary, as long as all sequence functions are used with consistent :start and :end arguments. However, a community-based 'standard' was developed in June/July 2001 on comp.lang.lisp; known as SPLIT-SEQUENCE (formerly PARTITION), it works as follows in its simplest form: split-sequence #\Space "A stitch in time saves nine. See similar questions...

Sect. 19) What is the "substring trap"?

Java Programmer's FAQ - Part D
The "substring trap" is the name for a mistake that is all too easy to make when using the substring() method of class String. The method signature is: public String substring(int beginIndex, int endIndex) Char 'a' is at position 1 in the String, and 'b' is at 2, which is 3-1. It seems to be done this way so that s.substring(0,s.length()) is equal to s. If so, the name of the second parameter should be something like endIndxPlusOne. But not the confusing and misleading endIndex. See similar questions...

How can find a string?

Exontrol Software - ExEdit FAQ page
The control provides Find and Replace support. The AllowFind property specifies whether the control can search for a string using the built-in Find dialog. By default, the AllowFind property is True. The control displays the Find dialog if the user presses CTRL+F key. See similar questions...

How can I count the number of frames in my metafile?

NCAR Graphics FAQ
We used to recommend using a script called "ncgm2gif" for converting NCGMs to GIF files. However, "ncgm2gif" has become a bit outdated, and there are better methods for converting to other raster formats. Our recommendation is to start with a PostScript (PS) or Encapsulated PostScript (EPS) file, and then use "convert" from the ImageMagick suite of tools to convert the PS file to another format like GIF, PNG, or even MPEG. You can get the ImageMagick suite from: http://www.imagemagick. See similar questions...

How can I count the number of entries a search found?

PerLDAP: Frequently Asked Questions
Using the information from the previous question, the answer is of course: $cld = $conn->getLD(); $res = $conn->getRes(); $count = Mozilla::LDAP::API::ldap_count_entries($cld, $res); Again, this is not really recommended, and this might change in future releases. One possibility is to add this feature as a native method, but I need to investigate this further, since v2.0 of PerLDAP might use asynchronous LDAP calls (for much better scalability). See similar questions...

Q10: How can I get a count of the number of items I have selected ?

Unofficial ANSYS HOWTO---FAQ
A10: The *get command will allow you to get just about any information you want about selected items and allow you to store the result in a parameter/variable. Here is an example that with count the selected nodes and put the result in NODECNT *get,NODECNT,node,,count See similar questions...

How can I show an int as a binary number - a string of 1s and 0s?

FAQ for the microsoft.public.languages.csharp newsgroup
The Convert class has an overload of the static ToString() method that takes two ints and returns a string populated with the number in the specified base. For instance, calling Convert.ToString(128, 2) will return "10000000". See similar questions...

Why should we use macro or const to replace number or string literals?

FAQ on C/C++/Unix by Roseanne Zhang, Java Programmer Certifi...
Read comments in the code. #include<iostream> using namespace std; class A { public: A(int a1,int a2) {x=a1; y=a2;} void print() const; // readonly parameter x1 void setX(const int x1) {x = x1;}n // y1 is allowed to change void setY(int y1) {y1++; y = y1;} // function is not allowed to change the class members int getXplusY() const { return x+y;} private: int x,y; }; void A::print() const { cout<<x<<":"<<y<<endl; //notice :!!!! } int main(){ A obj1(10,30); obj1. See similar questions...

How do I pad a string with blanks or pad a number with zeroes?

Found in /usr/local/lib/perl5/5.8.8/pod/perlfaq9.pod
In the following examples, $pad_len is the length to which you wish to pad the string, $text or $num contains the string to be padded, and $pad_char contains the padding character. You can use a single character string constant instead of the $pad_char variable if you know what it is in advance. And in the same way you can use an integer in place of $pad_len if you know the pad length in advance. The simplest method uses the "sprintf" function. See similar questions...

Do you deliver the string tags to a number of locations on behalf of customer?

Nationbright industries
Yes, we can provide this service especially when the customer of the string tag is a final buyer. It is because during the delivery process, our company information will inevitably showed in some documents. The consignee will know we are the manufacturer of the string tag. In this case, it might be harmful to the interest of string tag trader. If the string tag traders do not care about this, then we are well prepared to provide this service to them. See similar questions...

How do I convert a value (a number, for example) to a std::string?

Miscellaneous technical issues, C++ FAQ Lite
There are two easy ways to do this: you can use the <cstdio> facilities or the <iostream> library. In general, you should prefer the <iostream> library. The <iostream> library allows you to convert pretty much anything to a std::string using the following syntax (the example converts a double, but you could substitute pretty much anything that prints using the << operator): The std::ostringstream object o offers formatting facilities just like those for std::cout. See similar questions...

What are second order co-occurrences ?

NAME
These are the words that co-occur with co-occurrences of the target word. e.g. if the given bigram file includes bigrams like - telephone<>line<> product<>line<> market<>product<> telephone<>service<> then, telephone and product directly co-occur with line and hence become the (first order) co-occurrences of line, while, market and service co-occur with product and telephone resp. See similar questions...

Will I have to count calories?

FAQ's
No, the diet is very simple. You eat animal protein with all meals in addition to vegetables and fruit. See similar questions...

Explore Other Topics

How do I add a Carriage Return ("Enter") or Tab to data being scanned?
What do age spots, sun spots and liver spots look like?
How high should I hang my TV?
Do I need a passport and visa to travel in Spain?
How do I configure busybox?
Is there more caffeine in espresso than drip, or French Press?
What documentation does the applicant need to bring to closing?
Why do MonaVie Original and MonaVie Active contain the preservative polysorbate?
What are the benefits of core exercises?
How does UNICEF use the Convention on the Rights of the Child?
What subject matter does the MCAT cover?
What air conditioner works best with a gas furnace?
Every time I swim, my goggles get fogged up. How can I stop that from happening?
More Questions >>

© Copyright 2007-2012 QueryCAT
About • Webmasters • Contact