How to count a particular Character in a String

sunnyksunnyk Member Posts: 280
edited 2009-10-30 in Navision Attain
Hi,
How can i find the Count of a character appeared in a string.
For example suppose i have a string ABCDEFG@Yahoo.com,XYZ123@Yahoo.co.uk then if i want to find the Number of '@'. how can i do this using string function.

Answers

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Searches for the first occurrence of substring inside a string.

    Position := STRPOS(String, SubString)

    PS:use F1 or search before posting
  • sunnyksunnyk Member Posts: 280
    Dear Mohana,
    I used F1 but didn't found any function which count the occurrence of a character in a String.
    STRPOS gives the position of that character in a string and not the no of times that character appears in a string.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    sunnyk wrote:
    Dear Mohana,
    I used F1 but didn't found any function which count the occurrence of a character in a String.
    STRPOS gives the position of that character in a string and not the no of times that character appears in a string.
    #-o #-o
    [-( [-(
  • matteo_montanarimatteo_montanari Member Posts: 189
    sunnyk wrote:
    Hi,
    How can i find the Count of a character appeared in a string.
    For example suppose i have a string ABCDEFG@Yahoo.com,XYZ123@Yahoo.co.uk then if i want to find the Number of '@'. how can i do this using string function.

    Hi

    TextLine := 'yourtext';
    STRLEN(DELCHR(TextLine, '<=>', DELCHR(TextLine,'<=>', '@')));

    Bye

    Matteo
    Reno Sistemi Navision Developer
  • BeliasBelias Member Posts: 2,998
    STRLEN(DELCHR(TextLine, '=', DELCHR(TextLine,'=', '@')));
    
    this is enough (without '<' and '>'...)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • sunnyksunnyk Member Posts: 280
    Thank you :thumbsup:
  • Ephraim_07Ephraim_07 Member Posts: 9
    Belias wrote: »
    STRLEN(DELCHR(TextLine, '=', DELCHR(TextLine,'=', '@')));
    
    this is enough (without '<' and '>'...)

    This worked perfectly. Thanks
Sign In or Register to comment.