Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the function I came up with. Finally I found a way using limited knowledge of mine. It works, but probably performance is really bad.</p> <p>Thanks for your all help, they inspired me even though I can't directly use them because of advanced-for me- techniques. </p> <pre><code>void wildcard(string source, string search) { unsigned int j = 0, i = 0, z = 0; string s1 = "", search2 = search; //Starting with a null string and adding found parts to it /*************************IF IT STARTS WITH QUESTION MARK*************************/ if(search.find('?') == 0) { for(; search.at(z) == '?'; z++) //loop make search string start without question marks. { search2 = search.substr(z + 1, search.length()); } for(; j &lt;= source.length()-search2.length(); ++j) //application of Brute Force Search Algoritm for this case. { while(i &lt; search2.length() &amp;&amp; (source.at(z+i+j) == search2.at(i) || search2.at(i) == '?')) { s1 = s1 + source.at(z+j+i); i++; } } if(s1.length() == search2.length()) //showing results for this case. { cout &lt;&lt; "The matched string was found at index: " &lt;&lt; source.find(s1) - z &lt;&lt; endl; cout &lt;&lt; "The matched string is: " &lt;&lt; source.substr((source.find(s1)-z), search.length()) &lt;&lt; endl &lt;&lt; endl; } else { cout &lt;&lt; "The search string could not found in the source string." &lt;&lt; endl &lt;&lt; endl; } } /********************IF IT DOES NOT START WITH QUESTION MARK**********************/ else //If it doesnot start with ?, use normal test. { for(; j &lt;= source.length()-search.length(); ++j) //application of Brute Force Search Algoritm for this case. { while(i &lt; search.length() &amp;&amp; (source.at(i+j) == search.at(i) || search.at(i) == '?')) { s1 = s1 + source.at(j+i); i++; } } if(s1.length() == search.length()) //results { cout &lt;&lt; "The matched string was found at index: " &lt;&lt; source.find(s1) &lt;&lt; endl; cout &lt;&lt; "The matched string is: " &lt;&lt; s1 &lt;&lt; endl &lt;&lt; endl; } else { cout &lt;&lt; "The search string could not found in the source string." &lt;&lt; endl &lt;&lt; endl; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload