CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Posts
    73

    exclude characters from counting?

    Hello, I wanted to ask if you have a string like:
    Code:
    $my_s='ASRGREGTGTR----REGREGRE+++RRRRRR....';
    is there a way to count the length of the string, excluding non-word characters (+,- or .)?

    thank you

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: exclude characters from counting?

    You can create a temp string of only numbers and letters and count that.

    PHP Code:
    $tmp preg_replace('/[^0-9a-zA-Z]/i'''$my_s); 
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured