Professional Web Applications Themes

number filter - PHP Development

Hi all I have a little problem that I'm not sure how to solve. I have a message board type thing, when the messages are added they go though a bad word filter, but I need to filter out telephone numbers. I can't just say if incoming string has a number in it then remove as some people use numbers in their messages. What I need to say is if there are 4 or more numbers in a row then remove them. the way I would like to do it is check if the incoming string has a number in ...

  1. #1

    Default number filter

    Hi all

    I have a little problem that I'm not sure how to solve.

    I have a message board type thing, when the messages
    are added they go though a bad word filter, but I need
    to filter out telephone numbers.
    I can't just say if incoming string has a number in it then
    remove as some people use numbers in their messages.
    What I need to say is if there are 4 or more numbers
    in a row then remove them.

    the way I would like to do it is check if the incoming
    string has a number in it, if yes then run the filter.

    the trouble is not sure how to detect 4 or more numbers
    in a row and then remove them.

    Brian



    Brian Guest

  2. #2

    Default Re: number filter

    Am Sat, 26 Jun 2004 17:09:28 +0100 wrote Brian:
    > Hi all
    Hi,
    > [...]
    > the trouble is not sure how to detect 4 or more numbers
    > in a row and then remove them.
    You could use regular expressions

    $incoming_string = preg_replace('/(\d){4,}/im', '', $incoming_string);

    This would take 4 or more decimal digits in a row and remove it.


    HTH,
    Alex

    --
    What was your username again? - [url]http://members.iinet.net.au/~bofh/[/url]
    Alex Legler Guest

  3. #3

    Default Re: Re: number filter

    Brian wrote:
    > Hi all
    >
    > I have a little problem that Iím not sure how to solve.
    >
    > I have a message board type thing, when the messages
    > are added they go though a bad word filter, but I need
    > to filter out telephone numbers.
    > I canít just say if incoming string has a number in it then
    > remove as some people use numbers in their messages.
    > What I need to say is if there are 4 or more numbers
    > in a row then remove them.
    >
    > the way I would like to do it is check if the incoming
    > string has a number in it, if yes then run the filter.
    >
    > the trouble is not sure how to detect 4 or more numbers
    > in a row and then remove them.
    >
    > Brian
    I can give you one solution, but there are many ways to type a phone
    number.. so do a google search for "telephone number regular
    expressions"
    [url]http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=telephone+number+regular+expression[/url]

    --
    [url]http://www.dbForumz.com/[/url] This article was posted by author's request
    Articles individually checked for conformance to usenet standards
    Topic URL: [url]http://www.dbForumz.com/PHP-number-filter-ftopict123568.html[/url]
    Visit Topic URL to contact author (reg. req'd). Report abuse: [url]http://www.dbForumz.com/eform.php?p=411680[/url]
    steve Guest

Similar Threads

  1. #40499 [NEW]: filter sapi does not register any highlightning filter
    By php at henke37 dot cjb dot net in forum PHP Bugs
    Replies: 0
    Last Post: February 15th, 06:31 PM
  2. Replies: 3
    Last Post: September 12th, 04:18 PM
  3. int Number to text Number Function / UDF ?
    By cf_justin in forum Macromedia ColdFusion
    Replies: 0
    Last Post: April 15th, 04:02 PM
  4. sort from the smallest number to the highest number
    By Boon Chong Ang in forum PERL Beginners
    Replies: 3
    Last Post: January 30th, 03:00 PM
  5. XML Filter
    By rpjoseph in forum ASP Database
    Replies: 2
    Last Post: November 6th, 10:57 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139