Topic
  • 1 reply
  • Latest Post - ‏2007-06-13T15:37:05Z by nagkumar
SystemAdmin
SystemAdmin
210 Posts

Pinned topic How to perform Wild-card search in String Array?

‏2007-05-21T22:23:52Z |
Hi,

I have two String Arrays and want to create key-value pairs. To build that I use value from first array and need to search for wild-card string on the second array.

For example,

My first array contains date&timestamp and second array contains list of files and files names embeds dataTimestamp.

So, from first array for every value I need to search file names in second array and if I find matching value in

second array then I will be creating key-value pairs i.e array-of-array [ ] [ ].

This is how values in first and second array will look like. I can sort first array, but sort values for second array

will not be same sequence with first array. Hence, I need to search. Both are String Arrays.

Value from first array:
20070521104242689

Value from second array
EDI204_CS00555470_20070521104242689.txt

int index = Arrays.binarySearch(sortedArray, "*20070521104242689");

is not working for wild-card search.

Can anyone please help.

Thanks,
Siva
Updated on 2007-06-13T15:37:05Z at 2007-06-13T15:37:05Z by nagkumar
  • nagkumar
    nagkumar
    3 Posts

    Re: How to perform Wild-card search in String Array?

    ‏2007-06-13T15:37:05Z  
    Hi,

    You could iterate over the second array and use regular expression RegEx package to see if the array value matches.

    In fact Arrays class would internally does the interation on all the array elements.

    Regards,
    Raja Nagendra Kumar,
    C.T.O
    Competant and Reliable Offshore Code Varification Partners.
    www.tejasoft.com