xmlsearchtextwildcard

How to indicate the presence of wildcards without specifying it in the search string itself?


With regards to using XML, what is the most efficient and/or elegant way of indicating the presence of wildcards (Asterisk and Question Mark) in a search string without specifying it in the string itself?

For example, this is invalid:

<searchString>
   <searchFor>*cat??</searchFor>
</searchString>

and this is valid:

<searchString>
   <searchFor>cat</searchFor>
   <wildcards>
      <asterisk>
         <offset>0</offset>
      </asterisk>
      <questionMark>
         <offset>3</offset>
         <count>2</count>
      </questionMark>
   </wildcards>
</searchString>

Note that there is also a problem with the valid example above which is unable to specify the search string *??cat where two different types of wildcard characters occur with the same offset value. This must be taken care of as well.


Solution

  • You could use:

    <searchString>
        <asterisk/>
        <questionMark/>
        <questionMark/>
        <text>cat</text>
    </searchString>
    

    which resolves the final problem, and would be simple to transform to the full query string when you need it.