Since wildcards (*) are in your data, not in your queries, I think you should start by breaking your data apart. You must create an index table with columns such as:
dataGroup INT(11), exactString varchar(100), wildcardEnd varchar(100), wildcardStart varchar(100),
If you have a value of type "Folder1 / Folder2", save it in "exactString" and assign the identifier to the value in the master data table "dataGroup" in the above index table.
If you have a value of type "Folder1 / *", save the value of "Folder1 /" in "wildcardEnd" and again assign the identifier of the value in the main table to the "dataGroup" field in the above table.
Then you can match in your query using:
indexTable.wildcardEnd = LEFT('Folder1/WhatAmILookingFor/Data', LENGTH(indexTable.wildcardEnd))
This will truncate the search string ("Folder1 / WhatAmILookingFor / Data") to "Folder1 /" and then match it with the wildcardEnd field. I assume mysql is smart enough not to trim for each row, but start with the first character and match it with each row (using B-Tree indices).
A value like "* / Folder4" will go into the "wildcardStart" field, but it will be canceled. To quote Missy Elliot: “Is it worth it, let me work out? I put down my business, flipped it and canceled it” ( http://www.youtube.com/watch?v=Ke1MoSkanS4 ). Save the value "4redloF /" to "wildcardStart" ,. Then WHERE, as shown below, will match the lines:
indexTable.wildcardStart = LEFT(REVERSE('Folder1/WhatAmILookingFor/Folder4'), LENGTH(indexTable.wildcardStart))
Of course, you can do "REVERSE" already in your application logic.
Now about the difficult part. Something like "* / Fo * 4" should be split into two entries:
# Record 1 dataGroup ==> id of "*/Fo*4" in data table wildcardStart ==> oF/ wildcardEnd ==> /Fo
Now, if you agree with something, you need to make sure that each index record in the dataGroup is returned for full compliance and that there is no overlap. This can also be solved in SQL, but is beyond the scope of this question.