Regular expression to validate input

Results 1 to 2 of 2

Thread: Regular expression to validate input

  1. #1
    Jr. Johnson Guest

    Default Regular expression to validate input

    I have a form input field which accepts Keywords separated by commas. The end user can enter in as many keywords as they what. I need to construct a regular expression pattern that will check to make sure the end user entered their keywords separated by commas.

  2. #2
    Join Date
    Dec 1969

    Default RE: Regular expression to validate input

    *<BR>/^(s*w+s*,s*)+s*w+s*$/<BR><BR>This regular expression assumes that your keywords will all be single words and not phrases, so this isn&#039t allowed:<BR><BR>"once, upon a midnight, dreary"<BR><BR>It&#039s quite pragmatic about other spacing so this is ok:<BR><BR>"&nbsp;once, upon , a, midnight&nbsp;&nbsp&nbsp, &nbsp dreary "<BR><BR>Leading and trailing commas aren&#039t allowed:<BR><BR>", once, upon, a, midnight, dreary,"<BR><BR>Empty keywords are also disallowed (ie. "foo, , bar")<BR><BR>Good luck.<BR>

Posting Permissions

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