Re: Counting a Character

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



One way...
=SEARCH(LEFT(TRIM(SUBSTITUTE(A1,"."," ")),1),A1)-1

=substitute() replaces all the dots with spaces.

Then =trim() removes the leading spaces (and trailing and changes multiple
consecutive spaces to a single space.

Then the =left() takes the first character of that trimmed string and looks for
its position in the original string.

And then the formula subtracts 1.

If you could have something like:

.......
(no additional characters), you can add a dummy character to the string and do
the same thing:
=SEARCH(LEFT(TRIM(SUBSTITUTE(A1&"x","."," ")),1),A1&"x")-1



TCF wrote:

I have seen how to count the number of occurances of a particular character,
but is there a way to limit the count to just the left most characters? here
is my example

...PLATE - WELD, TAPPED, .312 - 18

i want to count only the left most "." in this case, it would be 3. If I
use the

=LEN(A1)-LEN(SUBSTITUTE(A1,".","") i get 4 because of the . in the .312.

any help would be appreciated.

thanks

--

Dave Peterson
.



Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)
  • Re: A note on computing thugs and coding bums
    ... code is valid for any character set that is legal in C (which is a ... characters in the required source character set ... A String, in C Sharp or Java, can be redefined. ... allow programmers to handle some other data format, ...
    (comp.programming)