Occurence of Char!

Discussion in 'ASP .Net' started by Mr Ideas Man, Feb 10, 2006.

  1. Mr Ideas Man

    Mr Ideas Man Guest

    Hi all,

    Can anyone tell me if vb.net contains a function that can tell me the number
    of times a character appears in a string.

    For example: Given the value ",34," the function would report that ','
    occurs twice.

    Cheers,
    Adam
    Mr Ideas Man, Feb 10, 2006
    #1
    1. Advertising

  2. Mr Ideas Man

    Terry Burns Guest

    There is no specific function AFAIK but here is a link to a simple function
    to do just that

    http://www.knowdotnet.com/articles/countoccurrences.html

    --
    Terry Burns
    http://TrainingOn.net


    "Mr Ideas Man" <> wrote in message
    news:OFx8T$...
    > Hi all,
    >
    > Can anyone tell me if vb.net contains a function that can tell me the
    > number of times a character appears in a string.
    >
    > For example: Given the value ",34," the function would report that ','
    > occurs twice.
    >
    > Cheers,
    > Adam
    >
    Terry Burns, Feb 10, 2006
    #2
    1. Advertising

  3. Adam,

    vb Dot net system.text.regularexpressions.regex has a matches function which
    does just what your looking for. Here are the devx tutorial links on regular
    expressions. http://www.devx.com/DevX/Article/10448?type=kbArticle&trk=MSCP

    Dim c As Integer
    c = System.Text.RegularExpressions.Regex.Matches(",34,", ",").Count

    Good Luck
    DWS

    "Terry Burns" wrote:

    > There is no specific function AFAIK but here is a link to a simple function
    > to do just that
    >
    > http://www.knowdotnet.com/articles/countoccurrences.html
    >
    > --
    > Terry Burns
    > http://TrainingOn.net
    >
    >
    > "Mr Ideas Man" <> wrote in message
    > news:OFx8T$...
    > > Hi all,
    > >
    > > Can anyone tell me if vb.net contains a function that can tell me the
    > > number of times a character appears in a string.
    > >
    > > For example: Given the value ",34," the function would report that ','
    > > occurs twice.
    > >
    > > Cheers,
    > > Adam
    > >

    >
    >
    >
    =?Utf-8?B?RFdT?=, Feb 10, 2006
    #3
  4. Mr Ideas Man

    Terry Burns Guest

    I dont use Regex much, thats an interesting one to remember.

    --
    Terry Burns
    http://TrainingOn.net
    "DWS" <> wrote in message
    news:...
    > Adam,
    >
    > vb Dot net system.text.regularexpressions.regex has a matches function
    > which
    > does just what your looking for. Here are the devx tutorial links on
    > regular
    > expressions.
    > http://www.devx.com/DevX/Article/10448?type=kbArticle&trk=MSCP
    >
    > Dim c As Integer
    > c = System.Text.RegularExpressions.Regex.Matches(",34,", ",").Count
    >
    > Good Luck
    > DWS
    >
    > "Terry Burns" wrote:
    >
    >> There is no specific function AFAIK but here is a link to a simple
    >> function
    >> to do just that
    >>
    >> http://www.knowdotnet.com/articles/countoccurrences.html
    >>
    >> --
    >> Terry Burns
    >> http://TrainingOn.net
    >>
    >>
    >> "Mr Ideas Man" <> wrote in message
    >> news:OFx8T$...
    >> > Hi all,
    >> >
    >> > Can anyone tell me if vb.net contains a function that can tell me the
    >> > number of times a character appears in a string.
    >> >
    >> > For example: Given the value ",34," the function would report that ','
    >> > occurs twice.
    >> >
    >> > Cheers,
    >> > Adam
    >> >

    >>
    >>
    >>
    Terry Burns, Feb 10, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. natG
    Replies:
    4
    Views:
    9,665
  2. wwj
    Replies:
    7
    Views:
    546
  3. wwj
    Replies:
    24
    Views:
    2,500
    Mike Wahler
    Nov 7, 2003
  4. Ben Pfaff
    Replies:
    5
    Views:
    470
    Tristan Miller
    Jan 17, 2004
  5. lovecreatesbeauty
    Replies:
    1
    Views:
    1,034
    Ian Collins
    May 9, 2006
Loading...

Share This Page