Options

How to count a particular Character in a String

sunnyksunnyk Member Posts: 276
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

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

    Position := STRPOS(String, SubString)

    PS:use F1 or search before posting
  • Options
    sunnyksunnyk Member Posts: 276
    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.
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    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
    [-( [-(
  • Options
    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
  • Options
    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
  • Options
    sunnyksunnyk Member Posts: 276
    Thank you :thumbsup:
  • Options
    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.