Advanced Item Search: Matches

I’m trying to use the advanced search to find Subject terms containing newline characters. I see the “matches” option and have tried a few queries, hoping that it is for searching with a regex pattern. Is that the case? If so, I must have an issue with my syntax. Any advice?

Here are a few queries I’ve attempted…

/\n/
"\n"
\r
\r?\n
/[\r\n]+/
(\r\n|\r|\n)

“matches” is a regex using MySQL’s regex syntax, described in their docs.

You definitely don’t need the / / delimiters. Have you tried just \n?

I tried \n but it returns a large number of false positive matches.

Doing a direct database query (below), I get the expected results.

SELECT * FROM `omeka_element_texts` WHERE `element_id` = 49 AND `text` REGEXP '\n' 

Hmmmmm, I suppose the problem here is that we, necessarily, escape the input from the user. MySQL’s ability to search for a newline character like this relies on being able to write a direct escape in a way that’s incompatible with us escaping the user’s input.

If the input here were a textarea instead of an input type="text" then you could write a literal newline in there and that should work correctly… it’s a bit of a conundrum.

1 Like

This makes sense. I’ll just search and make changes in PHPMyAdmin as needed when dealing with this specific issue.