1 Reply Latest reply on Dec 28, 2016 10:02 AM by BKBK

    RegExp question again (but w/ different beat)

    ghfftttyyudsderycv76 Level 1

      Hope we have some true regexp guru here...


      Here's a question. I have the following list.

      list = "id,option9,option10,option11,option12,option13,option14,option15,orderno,option10txt,opt ion11txt,option16"

      and I have a term called "optoin16", which does not match any exact item or element in the list, however, in this case,

      the last item, namely, option16, is the closest match, that is what I want.

      How do we construct a regular expression to find "option16" from this list based on "optoin16"?



        • 1. Re: RegExp question again (but w/ different beat)
          BKBK Adobe Community Professional & MVP

          You could match on indices (digits), like this


          <cfset matches = "">


          <cfset item="optoin16">

          <cfset list = "id,option9,option10,option11,option12,option13,option14,option15,orderno,option10txt,opt ion11txt,option16,option16blablabla">

          <cfset arrayItemIndex = reMatch("[\d]+",item)>


          <cfloop list="#list#" index="listElem">

              <cfset arrayListElementMatch = reMatch(".*(#arrayItemIndex[1]#).*",listElem)>

              <cfif arrayLen(arrayListElementMatch) GT 0>

                  <cfset matches = listAppend(matches,arrayListElementMatch[1])>