Feature Request - Regular Expression support for searching

Hi PoE Devs

Can you please add regular expression support to your search functions in the Inventory, Atlas and Passive Tree? The current search function is borderline useless. I.e. doesn't seem to work in the special stash tabs, can't handle multiple concurrently property searches, and in some string searches such as "ilvl: X" does not currently seem to work either?

Regular expression will help us build more complex search queries, making it a lot easier to manage large inventories, finding the best gear for our builds and finding suitable gear for vendor recipes. (Probably not so useful for small inventories, but what serious player has a small inventory?)

Not wanting to be presumptuous, but it does not seem very hard to add support for this either. I.e. assuming PoE is written in C++ I wrote a little example below to demonstrate how regular expression can be implemented by using standard C++11. (Sorry, it did not seem like "code" tags exist so I used "quote" instead.)

"

#include <iostream>
#include <vector>
#include <string>
#include <regex>

using namespace std;

int main()
{
// A sample item list. The list is build by concatenating all the item
// properties into a single string per item using spaces to separate the
// item properties. (C++17 support multi-line searches, so potentially can
// use newline characters instead of spaces if your compiler supports it.)
vector<string> items =
{
"name: Facebreaker Strapped Mitts "
"quality: 20 "
"ilvl: 60 "
"rlvl: 70 ",

"name: Loreweave Elegant Ringmai "
"quality: 10 "
"ilvl: 90 "
"rlvl: 64 ",

"name: Mystery Item "
"ilvl: 100 "
};

// EXAMPLE 1 - Search for items using a value range. In this case we are
// looking for all items 70 - 100.
// const string searchStr = "ilvl: ([7-9][0-9]|100)\\b";

// EXAMPLE 2 - Search for all items which are either greater than Lvl 70
// for chaos recipe, or greater than 0 quality for glass blowers recipe.
// const string searchStr = "ilvl: ([7-9][0-9]|100)\\b|quality: ([1-9]|[0-2][0-9])\b";

// EXAMPLE 3 - Search for a particular item with multiple properties. (This
// is an AND operation.) Good for finding items like rings with resists,
// or gear wherever multiple properties matter. In this case we are looking
// for a Lorewave with an item level of 70 or above.
const string searchStr = "(?=.*ilvl: ([7-9][0-9]|100)\\b)(?=.*name: Loreweave)";

cout << "SEARCH STRING: " << searchStr << endl << endl;

// Build the regex object from the search expression. Use case insensitive
// searches and the ECMAScript regex engine so we can use a web based regex
// validator. (https://regex101.com/) to test query strings.
const regex rgx(searchStr, regex::ECMAScript | regex::icase);

// Iterate through all the items.
for(const auto & item : items)
{
smatch match;
cout << "ITEM: " << item;
if(regex_search(item, match, rgx))
{
// If the item was found, this is where you would then highlight it. In
// this case we are just printing the match instead.
cout << " >>>>> MATCHED! (HIGHLIGHT THIS ITEM) <<<<< " << endl;
}
else
{
cout << ">>>>> NO MATCH (DONT HIGHLIGHT THIS ITEM) <<<<<" << endl;
}
cout << endl;
}

return 0;
}


-Cheers
Last bumped on Mar 13, 2020, 6:57:17 AM
This thread has been automatically archived. Replies are disabled.
I miss it too. I would be happy for few logical operators like or, not, >, <. Regex would be amazing.
+1
99% of the playerbase doesn't even know what regex is

Would be nice if the search did search through all the relevant information though.
"
yamface wrote:
99% of the playerbase doesn't even know what regex is

Would be nice if the search did search through all the relevant information though.


Yes. Regex is overkill, but logical operators would be huge QoL.
"
Vocasek9 wrote:
"
yamface wrote:
99% of the playerbase doesn't even know what regex is

Would be nice if the search did search through all the relevant information though.


Yes. Regex is overkill, but logical operators would be huge QoL.


Also not to forget that regex can be quite taxing if you fubars the search.
And yes... very easy to fubar a regex even if you didn't meant to do that.
So a ful regex would probably be a bad idea sadly.


But basic logical operators, now thats a good idea and should be safe.
Last edited by Dharall#1798 on Mar 13, 2020, 6:57:38 AM

Report Forum Post

Report Account:

Report Type

Additional Info