Results 1 to 3 of 3

Thread: Regex strip out all non alpha Characters from a String

  1. #1
    Join Date
    May 2009
    Posts
    45

    Regex strip out all non alpha Characters from a String

    I have created a code where there are many non alpha characters in string and now i want to replace all those non-alpha characters with a # sign.

    For example if in my code there is a string There are many numbers like 1234-78.*.25.*.65 , Over here i want to replace * with # sign.Can anyone tell me what should be the code which i need to write.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: regex strip out all non alpha

    Try to use the following code for replacing non alpha Characters from a String

    Code:
    Function Demo(ByVal input As String) As String
    
      Dim ab As String = "[1234-78.*.25.*.65]"
    
      Dim xy As String = "#"
    
      Demo = Regex.Replace(input, ab,xy)
     
    
    End Function

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Replace non alpha Characters from a String

    If you want replace non alpha Characters from a string by using PHP then use the following code.

    PHP Code:
    <?php

    $string 
    preg_replace('/[^a-z0-9*]/i'''$string);

    $string str_replace('*''%'$string);
    ?>

Similar Threads

  1. Problem in retrieving string with Regex
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 05:53 AM
  2. Regex - compose a string
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 09-02-2010, 01:38 AM
  3. Regex string with quotes
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 07-02-2010, 06:03 AM
  4. Problem with Regex in returning string
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 05-02-2010, 03:37 AM
  5. Regex replace an integer with string
    By New ID in forum Software Development
    Replies: 5
    Last Post: 05-02-2010, 01:35 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,121,435.89905 seconds with 17 queries