Skip to main content
Participating Frequently
May 21, 2009
Question

Regular expression on form value

  • May 21, 2009
  • 2 replies
  • 551 views

I have a form value that I need to add a regular expression to the end so I can pick up any characters after the form value.

Example if someone enters Jones then I want to make sure the value could also search Jones Jr or Jones Sr.

Basically add a space and any characters a-z to the form value.

Here is my attempt but lost on regular expression part:

REReplace ("form.myvalue","[[:space:]]","Not sure what the regular expression would be here?","ALL")

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    May 24, 2009

    I assume you're looking for a way to construct a regular-expression search term for a given user input. I also assume that a space and one word may optionally follow the user input. Then, one possibility is

    <cfset searchTerm =  "(#form.myvalue#[\s]*[A-Za-z]*)">

    Participating Frequently
    May 22, 2009

    This will replace "Jones Jr" and "Jones Sr" in the following text:

    "this is a test text Jones Jr and Jones Sr"

    Mack