Skip to main content
February 15, 2009
Question

Regular Expressions

  • February 15, 2009
  • 1 reply
  • 242 views
I have a search application where a user can input search strings into a text box and submit.

If the user enters for example: website "content approval" new

What would the regular expression be to extract the 3 words:
1) website
2) content approval
3) new

There are also other scenarios that a user can enter, so it will need to work for all cases.
    This topic has been closed for replies.

    1 reply

    February 16, 2009
    If you want to match the three words in other words any of them.
    split the string and create a regex for each word the i flag will set an ignore case, the g flag will get all matches, consider creating one for the three words together and prioritize it in the results as one is likely to prefer a full match and then any other match. the general syntax would be
    /website/gi;
    /new/gi;
    /content approval/gi;
    i am unsure about the syntax specific for the use of regex with CF. But it should be something like that since it is java based.