How do I count the number of *'s in a string?
I need to count the number of * in a string of carakters. And the return the number. 0 for no *'s in the string 2 for two *'s in the string and so on.
It's probably quite simple but I can't figure out how!
Like this.
james_t_dk wrote in message
news:[email protected]..
> I need to count the number of * in a string of carakters. And the
> return the number. 0 for no *'s in the string 2 for two *'s in the
> string and so on.
>
> It's probably quite simple but I can't figure out how!
[Attachment Untitled 10.vi, see below]
Attachments:
Untitled_10.vi 18 KB
Similar Messages
-
How i can count the number of words in a string?
hi, i want to know how to count the number of words in a string
e.g. java is a very powerful computer language.
i will get 7 words.
thanks in advance..Jverd, this has actually been answered, but due to an
attack of goldie-itis, all the answers were hosed.
The OP did get an answer, though.Yeah, I know. I just didn't know if he saw the answer before it went away. -
How do I count the number of occurrences of a string within a group of cells?
Hello all, I'm trying to figure out how to count the number of times a child has completed certain tasks. Here is a sample of the data (it is highly simplified here, but contains what I hope is needed to answer my question):
Unnamed Table
Objective
John
Ann
Alex
Dave
Eric
20a 20b 20c
x
20a 20b 20c
x
20a 20b 20c
x
x
19b 20a
x
x
20c 21b 22
x
What I am trying to do is count the number of times each child completed each objective - but I can't figure out how to go about splicing up the "objectives" fields for counting while still being able to compare them to whether or not the "child" has 'an x in the box' in that particular row.If I read your example correctly, John's counts should be 2 for 20a, 1 for 19b, 20b and 20c, and 0 for any other objectives listed.
Here's an example that will work for your data set, assuming that any objective ma occur only once in each row of column A of the Main table. I've added an a to objective 22, but I think it is unnecessary, provided there is no objective 122, 221, etc.
This uses a two step process.
The table AUX extracts the objectives completed by each student, using the checkboxes in Main. Note that it also adds a space at the beginning and end of each string. This provides an extra character before the first objective code and after the last objective code in that row, used by the wildcard specification in the formula in the Summary table.
Formula:
Aux::B2: =IF(OFFSET(Data :: $A$1,ROW()-1,COLUMN()-1)," "&OFFSET(Data :: $A$1,ROW()-1,0)&" ","")
Fill right to the last column and down to the last row of Aux.
Summary uses COUNTIF to count the number of occurrences of each of the objectives listed in column A of that table.
Formula:
Summary::B2: =COUNTIF(Aux :: B,"=*"&$A2&"*")
Fill right and down as the previous formula.
Regards,
Barry -
How do I count the number of records returned in the CMIS query
How do I count the number of records returned in the query CMIS?
SELECT COUNT(*) FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition = \'RD_PROJETOS_EXCLUSIVOS\''}
Euler HomeroHi Euler,
interestingly enough, the reference guide for CMIS ( http://wiki.alfresco.com/wiki/CMIS_Query_Language ) that I found does not mention the COUNT function at all. On the other hand it states that: "The SELECT clause identifies which virtual columns to return in the result set. It can be either a comma-separated list of one or more queryNames of properties that are defined by queryable object types or * for all virtual columns."
There are, however, some other posts like e.g. http://alfrescoshare.wordpress.com/2010/01/20/count-the-total-number-of-documents-in-alfresco-using-sql/ which state that they could make it working.
Having asked in the WebCenter Portal forum, I assume that your content repository is WebCenter Content. The CMIS doc for the Content is available here: http://docs.oracle.com/cd/E23943_01/doc.1111/e15813.pdf (no COUNT there either). It does, however, mention explicitly that "CMIS queries return a Result Set where each Entry object will contain only the properties that were specified in the query.". This means your could rather investigate the Result Set. Note that there are also other means than CMIS how to get the requested result set (e.g. calling a search service directly via so-called RIDC).
In the given context I am also interested what your use case is. OOTB CMIS in WebCenter Portal is used, for instance, in Content Presenter, where it is content rather than "parameters" what's displayed. -
Count the number of occurrence in a string
is there any api for counting the number of occurrence in a string or should i write a method myself?
for example. I want to count "." in "1.2.3.4.". i want to count the dot in this string.
I am just wondering.
Thanks in advance.is there any api for counting the number of
occurrence in a string or should i write a method
myself?The latter. -
Which method to count the number of character in a string?
Hi all,
I want to know which class and method to count the number of character in a string?
Garyhttp://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
-
How do I count the number of cells with a particular text in it?
I have a column with peoples name in each cell. I want to count the numbe rof times a persons name appears in the column. How do I do this? any help would be great ! thanks in advance.
Hi Evilhomer,
The function COUNTIF will do this. Here are two Tables on one sheet. Table 1 contains names in Column B.
Table 2 contains the names once only (in any order) in Column A, with a COUNTIF formula in Column B to count how many times a name occurs in Table 1.
The formula in Sheet 2, Cell B2 is:
=COUNTIF(Table 1 :: B2:B5,A2)
Enter the formula in B2 then copy down.
It is easier to create the two tables on one sheet. If you then want to move a table to another sheet, Numbers will convert the formulas to keep the references valid.
There are other ways to do what you want. Please reply if this is not what you want.
Regards,
Ian. -
How count the number of substrings in a string
Hi all,
I wonder if someone can help me and point out where I'm going wrong.
I want to count the number of substring starting with 'd' and ending with 'e' in a string supplied by a user.
currently my code is only counting the number of 'd' and 'e' characters in the string.
public static void main (String [] args)
Scanner input = new Scanner (System.in);
String mstring;// string variable that the user will enter
int i = 0; // upstep variable
int count = 0; // int variable to count the number of substrings
System.out.print("Enter a string: ");
mstring = input.nextLine();
while (i != mstring.length())
if(mstring.charAt(i)=='d'){count++;}
else if (mstring.charAt(i)=='e'){count++;}
i++;
System.out.println("The total d e substrings is " + count);
}For example if the user enters adbedeaadffe the total number of substrings should be 5 but I'm getting 6 as the program is just counting the number of times it comes across 'd' and 'e'
Can anyone shed some light on this for me thanks.Hi all I had a good few replies to this question but they seem to have been removed from the system for some reason.
I've changed my code slightly and it works but only for one round of the guard.
Scanner input = new Scanner (System.in)
String mstring;// main string variable that the user will enter
int i = 0; // upstep variable
int count = 0; // int variable to count the number of substrings
System.out.print("Enter a string: ");
mstring = input.nextLine();
int y =mstring.length();
while (i != mstring.length() && y !=0)
if (mstring.charAt(i) == 'd' && mstring.charAt(y-1)=='e'){count = count+1;}
y--;
i++;
System.out.println("The total a b substrings is " + (count));The above code will only print out one substring of adbedeaadffe but that is not what I need, I need to be able to print out all of the substrings.
Can anyone tell me where I'm going wrong.
Thanks in advance -
How can I count the number of unique cells?
I have a column in my spreadsheet that looks like this:
Date
Items
3/25
Item A
3/27
Item A
3/29
Item A
3/25
Item A
4/25
Item B
6/1
Item B
7/13
Item B
8/9
Item B
3/5
Item C
1/2
Item C
5/15
Item D
3/25
Item D
What I want is something that will list all the unique items that I have and count the number of times that Item shows up in my spreadsheet. For example, the results should look like this:
Item A: 3
Item B: 4
Item C: 2
Item D: 2
I thought for sure that I can do a chart in numbers and it would count the number of items but no, not so much.I apologize. When I pasted the table in Numbers running in French the values of column B were treated as dates.
I leave the screenshot untouched because the contents of this column changes nothing to the calculations.
In cell D2 of the main table, the formula is :
=IF(ISBLANK(C),0,IF(COUNTIF($C$2:$C2,"="&$C2)=1,COUNTIF(C,"="&$C2)+(ROWS(A)-ROW( ))/100000,0))
Apply Fill Down
In cell A2 of table aux, the formula is :
=IFERROR(LARGE(main :: D,ROW()-1),"")
In cell B2 of table aux, the formula is :
=IF(A>0,LOOKUP(A2,main :: D,main :: C),"")
In cell C2 of table aux, the formula is :
=INT(A)
Apply Fill Down
Yvan KOENIG (VALLAURIS, France) samedi 6 août 2011 23:33:10
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
My iDisk is : <http://public.me.com/koenigyvan>
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer ! -
How can I count the number of times a timed loop finished late?
I am getting occasional timing errors in a timed loop under windows XP and would like to count the number of errors, but I can't find a simple software counter vi
The timed loop has a terminal (boolean) to indicate if the previous iteration finished late. Just increment an integer shift register if this happens.
The attached shows a very simple demo (LabVIEW 7.1).
LabVIEW Champion . Do more with less code and in less time .
Attachments:
LateCounter.vi 76 KB -
A quick way to count the number of newlines '/n' in string of 200 chars
I am trying to establish the number of lines that a string will generate.
I can do this by counting the number of '/n' in the string. However my brute force method (shown below) is very slow.
Normally this would not be a problem on a 2800mhz Athlon (Standard) PC this takes < 1 second. However this code resides within a speed critical loop (not shown). The code shown below is a Achilles heal as far as the performance of this speed critical loop goes.
Can anyone suggest a faster way to count the number of �/n� (new lines) within a text string of around 50- 1000 chars, given that there may be 10 � 100 newline chars. Speed is a very important factor for this part of my program.
Thanks in advance
Andrew.
int lineCount =0;
String txt = this.getText();
//loop throught text and count the carridge returns
for (int i = 0; i < txt.length(); i++)
char ch = txt.charAt(i);
if (ch == '\n')
lineCount ++;
}//end forMessage was edited by:
scottie_uk
Message was edited by:
scottie_ukWell, here is a C version. On my computer the Java version (reply 9 above) is slightly faster than C. YMMV. For stuff like this a compiler can be hard to beat even with assembler, as you need to do manual loop unrolling and method inlining which turn assembly into a maintenance nightmare.
// gcc -O6 -fomit-frame-pointer -funroll-loops -finline -o newlines.exe newlines.c
#include <stdio.h>
#include <string.h>
#if defined(__GNUC__) || defined(__unix__)
#include <time.h>
#include <sys/time.h>
#else
#include <windows.h>
#endif
#if defined(__GNUC__) || defined(__unix__)
typedef struct timeval TIMESTAMP;
void currentTime(struct timeval *time)
gettimeofday(time, NULL);
int milliseconds(struct timeval *start, struct timeval *end)
int usec = (end->tv_sec - start->tv_sec) * 1000000 +
end->tv_usec - start->tv_usec;
return (usec + 500) / 1000;
#else
typedef FILETIME TIMESTAMP;
void currentTime(FILETIME *time)
GetSystemTimeAsFileTime(time);
int milliseconds(FILETIME *start, FILETIME *end)
int usec = (end->dwHighDateTime - start->dwHighDateTime) * 1000000L +
end->dwLowDateTime - start->dwLowDateTime;
return (usec + 500) / 1000;
#endif
static int count(register char *txt)
register int count = 0;
register int c;
while (c = *txt++)
if (c == '\n')
count++;
return count;
static void doit(char *str)
TIMESTAMP start, end;
long time;
register int n;
int total = 0;
currentTime(&start);
for (n = 0; n < 1000000; n++)
total += count(str);
currentTime(&end);
time = milliseconds(&start, &end);
total *= 4;
printf("time %ld, total %d\n", time, total);
fflush(stdout);
int main(int argc, char **argv)
char buf[1024];
int n;
for (n = 0; n < 256 / 4; n++)
strcat(buf, "abc\n");
for (n = 0; n < 5; n++)
doit(buf);
} -
How do I count the number of unread emails in WebCenter ?
how can I show unread emails counter on webcenter spaces ( I used the default WC Mail task flow )
Hi Euler,
interestingly enough, the reference guide for CMIS ( http://wiki.alfresco.com/wiki/CMIS_Query_Language ) that I found does not mention the COUNT function at all. On the other hand it states that: "The SELECT clause identifies which virtual columns to return in the result set. It can be either a comma-separated list of one or more queryNames of properties that are defined by queryable object types or * for all virtual columns."
There are, however, some other posts like e.g. http://alfrescoshare.wordpress.com/2010/01/20/count-the-total-number-of-documents-in-alfresco-using-sql/ which state that they could make it working.
Having asked in the WebCenter Portal forum, I assume that your content repository is WebCenter Content. The CMIS doc for the Content is available here: http://docs.oracle.com/cd/E23943_01/doc.1111/e15813.pdf (no COUNT there either). It does, however, mention explicitly that "CMIS queries return a Result Set where each Entry object will contain only the properties that were specified in the query.". This means your could rather investigate the Result Set. Note that there are also other means than CMIS how to get the requested result set (e.g. calling a search service directly via so-called RIDC).
In the given context I am also interested what your use case is. OOTB CMIS in WebCenter Portal is used, for instance, in Content Presenter, where it is content rather than "parameters" what's displayed. -
How do I count the number of times a word appears in a column?
What I have is a spreadsheet logging work history. Let's say the work location is "office", "home", or "travel" and I want to have a separate cell in another table for totals, count up the number of time each appears in the data for the year. So it would look like this:
Date
Location
sept 1
office
sept 2
home
sept 3
home
sept 4
travel
sept 5
office
sept 6
office
sept 7
office
sept 8
travel
sept 9
home
sept 10
office
Totals
Days
10
Office
5
Home
3
Travel
2
I just can't figure out how to develop the formula to put in the Totals column to make it work this way. If you can help me achieve this I'd really appreciate it!Hi SpartanAntarctican,
Table 1 to record your locations
Date
Location
sept 1
office
sept 2
home
sept 3
home
sept 4
travel
sept 5
office
sept 6
office
sept 7
office
sept 8
travel
sept 9
home
sept 10
office
Table 2 to sum your locations
Totals
Days
10
Office
5
Home
3
Travel
2
In Table 2 the formula in B2
=ROWS(Table 1::A)−1
Minus 1 because there is a Header Row in Table 1.
In Table 2 the formula in B3 (and Fill Down)
=COUNTIF(Table 1::B,A3)
You can check this by adding 5 + 3 + 2 to arrive at 10
Or maybe delete Row 2 put the Days calculation into a Footer Row in Table 2
=SUM(B) .
Regards,
Ian. -
I'm using Numbers 3.2 and would like to count the names in a column which satisfy a condition in a different column. There are 3 "streams" through which these names have come to me, and I would like to easily identify how many have come from each stream. Any help?
Hi DirtyDawg,
COUNTIF is your friend here.
If your source is in column C and your streams are 1, 2 and 3:
=COUNTIF(C,"=stream1")
=COUNTIF(C,"=stream2")
=COUNTIF(C,"=stream3")
These need to be in a footer or header row or in a different column than C.
hope this helps,
quinn -
How do i count the number of times a cell has been referenced by other cells' formulae?
Hello,
I have a spreadsheet of recipes and ingredients that use checkboxes to let me know which recipes I can make based on the ingredients I have on-hand, using a formula like this one: =IF(AND('Spirits' :: A42,Mixers :: A18,Mixers :: A41,'Spirits' :: A25 ),Table 3 :: $A$2,Table 3 :: $A$3). If I've checked all of the boxes for ingredients that are required for any one of my recipes, the cell that the formula is in returns something like "YES"; otherwise, it returns a blank. It works well enough, but I'd like to include a cell next to each ingredient with a formula that will look through the hundreds of recipes, which all use a formula like the one above, and return a count of the number of times the ingredient's cell is referenced in those formulas. That way, I'll know which ingredients are the most commonly used in my eclectic collection of recipes. I thought something like =COUNTIF('Recipes' :: A2:A343, "=A2") would work, but it doesn't look at the cell references in the formulas, so no, it doesn't work. Any ideas? I'm using Numbers 2.3Hello
There's no formula to inspect other formula in Numbers. So what you asked cannot be achived in such a way you described.
A simple alternative method would be to build recipe-ingredient matrix as follows.
E.g.
Table definitions:
Recipes
A1 Recipe \ Ingredient
A2 A
A3 B
A4 C
A5 D
A6 E
A7 F
A8 # recipes / ingredient
B1 X1
B2 TRUE
B3 FALSE
B4 TRUE
B5 FALSE
B6 TRUE
B7 FALSE
B8 =COUNTIF(B,TRUE)
C1 X2
C2 TRUE
C3 TRUE
C4 FALSE
C5 TRUE
C6 TRUE
C7 TRUE
C8 =COUNTIF(C,TRUE)
D1 X3
D2 FALSE
D3 TRUE
D4 FALSE
D5 TRUE
D6 FALSE
D7 TRUE
D8 =COUNTIF(D,TRUE)
E1 X4
E2 FALSE
E3 FALSE
E4 FALSE
E5 FALSE
E6 FALSE
E7 TRUE
E8 =COUNTIF(E,TRUE)
F1 Y1
F2 TRUE
F3 FALSE
F4 TRUE
F5 TRUE
F6 TRUE
F7 FALSE
F8 =COUNTIF(F,TRUE)
G1 Y2
G2 FALSE
G3 TRUE
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FALSE
B4 TRUE
B5 FALSE
C1 code
C2 =IF(B2,1,0)
C3 =IF(B3,1,0)
C4 =IF(B4,1,0)
C5 =IF(B5,1,0)
In "Recipe" table, the first row is header row and the last row is footer row.
Hope this may help,
H
Maybe you are looking for
-
We're trying to set up a SAML integration with our Flex/BlazeDS app. It is not going well. By not going well I mean we can't figure out how to get the @#%@# thing to work. We're very experienced with Flex, REST, SOAP, etc. but SAML is something we
-
Data services job failes while insert data into SQL server from Linux
SAP data services (data quality) server is running on LInux server and Windows. Data services jobs which uses the ODBC driver to connect to SQL server is failing after selecting few thousand records with following reason as per data services log on L
-
Extract data from SolMan to MS Access with VB RFC
I am trying to create a database that allows me to extract data from SolMan directly from MS Access. The command I want to run is ZSPROJECT_GET_SOLAR_STATUS (I think this will do what I want it to). I am doing this in VB within Access and need to e
-
Cannot display a named part of a HTML page
Hallo, I want to display a named part of a HTML page in a JEditorFrame. I have index.html and a part of it is named with <a name="label1"> My Java code looks as follows url = this.getClass().getResource("/Res/index.html#label1");However, I get n
-
Controlling VI Logger 1.1.1 with LabVIEW 7.1
I have LabVIEW 7.1 on my system and installed VI Logger (1.1 them upgraded to 1.1.1). I would like to programatically control VI Logger with LabVIEW. There are references to VIs under the Advanced pallate to do just that, but I cannot find them or an