INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Whole word search in Smartlists  (Read 1130 times)

TAJ-767

  • Recent member
  • *
  • Posts: 14
Whole word search in Smartlists
« on: December 22, 2020, 03:37:25 pm »

I'm trying to coordinate the way track names use abbreviations for "number" - #1, nr.1, No. 1, No.1, No 1, etc.  In the end, I'd like everything to be in the format "No. 1"

I tried to set up a smartlist to show the non-conforming abbreviations of "number."  But that turned out to be trickier than I expected for my level of search language skills (which doesn't currently include RegEx).

Here's the problematic subset of what I'm trying to do: 
I want to capture all instances of "No #" and "No.#" and I don't want to capture any instances of "No. #" or words with "no" somewhere in them.

What I thought I could do is select all files with the whole word "No" in them, but without the string "No. " in them.  (I know this is imperfect - it won't capture "Track No 1 and No. 2", for example, but bear with me for a minute.)

I put the following into my search expression:  [name]=^No -[name]="No. "

The results didn't look right, so I opened the Smartlist rules again to make sure I didn't do anything obviously wrong.  Here's what it showed: [name]="No" -[name]="No. "
The problem with this, of course, is that it captures track names that have the letter combination "no" anywhere in them ("Nobody Knows the Trouble I've Seen").  There are a lot of those that I'm trying to filter out.

I assumed I made some error in entering or saving the search expression, so I changed it back to:   [name]=^No -[name]="No. "

I hit apply, nothing changed, and when I opened the Import/Export window again, it showed:   [name]="No" -[name]="No. "

It is changing ^No to "No" on me behind the scenes.

I double checked the search language Wiki page:


^word    Restricts matching to a full word. A word is broken by space, punctuation, etc.
                Example: Match car as a full word, as in A Car for All, but not Barcarolle.
                ^car


Question 1:  Am I doing something wrong?
Question 2:  How can I use "search for a whole word" in a smartlist?
Question 3:  Can I and should I be using RegEx for this?


Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Whole word search in Smartlists
« Reply #1 on: December 22, 2020, 03:52:53 pm »

If you have not read the JRiver search language wiki, google it. It provides info you will need.

You can accomplish what you want using grouping operators. See the wiki.

Alternatively, if that proves too difficult for you, just make a smartlist for each case. You will find them all with multiple smartlists as completely as with one.
Logged

TAJ-767

  • Recent member
  • *
  • Posts: 14
Re: Whole word search in Smartlists
« Reply #2 on: December 22, 2020, 04:07:37 pm »

Thanks for your quick response.  The text in blue above was quoted from the Wiki; I did check the Wiki (and try to search the forum) first.

The problem isn't the grouping - I get how to do that.  The problem is that the smartlist won't accept this:

  [Name]=^No

even though the Wiki says that's exactly the syntax I need to select names that have the whole word "No" in them (and not things like "Nobody" or "Knows").

I tested this by making a smartlist with just the default [Media Type]=[Audio] and the expression above using the smartlist rules importer/exporter:

  [Media Type]=[Audio] [Name]=^No

When I clcked "Ok" and then re-opened it in the smartlist rules importer/exporter, I had this:

  [Media Type]=[Audio] [Name]="No"

If there is something in the Wiki that explains how to get the smartlist to accept ^No instead of changing it to "No", I'm not smart enough to find it, so I would appreciate your help in locating it.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Whole word search in Smartlists
« Reply #3 on: December 22, 2020, 04:30:31 pm »

I don't have access to MC at the moment, I'm just going from memory to help you. Which means I'm not able to try something out and give you a cut and paste solution.

To do what you described you will need grouping, so good if you know how to do it.

Seems like weirdness of the import export dialog, or maybe there is something wrong with your syntax. The wizard should avoid that.

Use the wizard to create a rule Name contains ^No

Don't use the import export, just try the wizard and see if the rule works. It should.

You might have to escape the ^ character, as in [Name]="/^No"  in the import/export. I can't test for you.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: Whole word search in Smartlists
« Reply #4 on: December 22, 2020, 05:00:14 pm »

What about using an Expression with Regex?
Code: [Select]
[=regex([name],/#\b(nr|no|n|#)[\.\s#]*\d+#/,0)]=1
Logged

TAJ-767

  • Recent member
  • *
  • Posts: 14
Re: Whole word search in Smartlists
« Reply #5 on: December 22, 2020, 05:04:18 pm »

Thanks again for the suggestions.  The Wizard has options that are the equivalent of the following import/export syntaxes (in order):

  [Name]=[No],  -[Name]=[No]  (Name is, Name is not)
  [Name]="No",  -[Name]="No"  (Name contains, Name doesn't contain)
  [Name]=[No",  -[Name]=[No"  (Name starts with, Name does not start with)
  [Name]="No],  -[Name]="No]  (Name ends with, Name does not end with)

When I do this

  [Name]=^"No"

or

  [Name]=/^"No"

it gets converted to this

  [Name] = "/"No" (Name contains "No )

So it looks like it understands that it should do something with the ^ symbol, but is doing the wrong thing with it.

When I do this:

  [Name]="/^No"

or when I do this:

  [Name]="^No"

it gets converted back to this again:

  [Name] = "No"


It is starting to look a lot like a bug....
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Whole word search in Smartlists
« Reply #6 on: December 22, 2020, 05:13:25 pm »

I know what the wizard has.

Use the wizard to create a rule Name contains ^No

Don't use the import export, just try the wizard and see if the rule works. It should.

Did you try what I said?  Do that exactly. No quotes, no import export, no extra nonsense.

Don't touch the import export at all. Create a new smartlist. Add the rule I told you and apply it.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: Whole word search in Smartlists
« Reply #7 on: December 22, 2020, 05:15:13 pm »

You can select "Custom" on the field name and then paste the Expression I gave above.
You can also click on Import/Export and paste the expression there.

The Regex expression above will filter all variations of no/nr/n/# plus a number, including the correct ones you want to exclude.
To exclude the correct ones, a more complex expression is needed... try this:

Code: [Select]
[=and(isequal(Regex([name],/#\bno\. #\d+#/,0),0), regex([name],/#\b(nr|no|n|#)[\.\s#]*\d+#/,0))]=1
Wer is providing a solution, this is a different one. Try both :)
Logged

TAJ-767

  • Recent member
  • *
  • Posts: 14
Re: Whole word search in Smartlists
« Reply #8 on: December 22, 2020, 05:22:51 pm »

Did you try what I said?  Do that exactly. No quotes, no import export, no extra nonsense.

I did not - I didn't understand what you said.

But I get what you mean now.

I tried it, and it worked...but

When I open Import/Export, it shows the syntax  [Name]="/^No"
But when I close Import/Export, it converts that back to [Name]="No"

So there is definitely a bug in the behavior of the Import/Export editor.

Thanks!
Logged

TAJ-767

  • Recent member
  • *
  • Posts: 14
Re: Whole word search in Smartlists
« Reply #9 on: December 22, 2020, 05:24:14 pm »

What about using an Expression with Regex?
[=regex([name],/#\b(nr|no|n|#)[\.\s#]*\d+#/,0)]=1

Thanks for this - I wasn't sure if I could use RegEx in the smartlist Search, but I plugged this in and it seems to work (when coupled with -[Name]="No. ").

Now I have to learn RegEx....

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Whole word search in Smartlists
« Reply #10 on: December 22, 2020, 05:39:17 pm »

Regex shouldn't be necessary for this, as it's directly supported by the search language.

Zybex, if you can firm that the import/export dialog corrupts the example I gave him, that's a bug that should be fixed.

TA, you should be able to build the necessary syntax using the wizard; just avoid the import export for now if it is causing a problem.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2674
Re: Whole word search in Smartlists
« Reply #11 on: December 22, 2020, 05:44:15 pm »

It does do that, some weird behavior with the ^ char.
The advantage of regex here is the ability to filter for multiple combinations, separators and digits, as well as enforcing a Word boundary with \b. It's relatively heavy but more precise in this case.
Logged

TAJ-767

  • Recent member
  • *
  • Posts: 14
Re: Whole word search in Smartlists
« Reply #12 on: December 22, 2020, 05:47:18 pm »

Thanks again - I've been able to get both strategies (Wizard w/o Import/Export editing and RegEx) to work.

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Whole word search in Smartlists
« Reply #13 on: December 22, 2020, 06:43:14 pm »

The advantage of regex here is the ability to filter for multiple combinations, separators and digits, as well as enforcing a Word boundary with \b.

All true. But the disadvantage is 99.9% of users aren't up to using it.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Whole word search in Smartlists
« Reply #14 on: January 21, 2021, 03:00:41 pm »

Just to close the loop on this, this issue has been addressed in the latest release of MC with a change to the editor.  There is now a dropdown selection for "contains whole word."
Logged
Pages: [1]   Go Up