# Strstr broken? result is always 0

**URL:** https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942
**Category:** No Bugs
**Created:** [April 30, 2011, 3:21pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942 "2011-04-30T15:21:28Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![anon40688970](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@anon40688970](https://community.mp3tag.de/u/anon40688970)
#### Post date: [April 30, 2011, 3:21pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/1 "2011-04-30T15:21:28Z")

</div>

I tried to use $strstr inside a format value action. It did not work in every combination i tried. I ended up with something like

Format Value  
Field: Title  
Format String: $strstr(%\_filename%, "e")

The filename of course contained the character 'e'. The result was, as in my previous tests, 0. Is this the expected result?

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [April 30, 2011, 3:32pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/2 "2011-04-30T15:32:57Z")

</div>

> [@anon40688970](#):
>
> I tried to use $strstr inside a format value action. ... The filename of course contained the character 'e'. The result was, as in my previous tests, 0. Is this the expected result?...

Try it using the correct syntax:

**$strstr(%\_filename%,'e')**

Result: 15  
Filename: Albinoni-Trumpet Concerto

This works too when searching only for one character:

**$strchr(%\_filename%,'e')**

Result: 15  
Filename: Albinoni-Trumpet Concerto

But what should bring this expression in an action 'Format Value' on the tag-field TITLE?

DD.20110430.1938.CEST

---

<div class="post-metadata">

### Author: ![anon40688970](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@anon40688970](https://community.mp3tag.de/u/anon40688970)
#### Post date: [April 30, 2011, 3:52pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/3 "2011-04-30T15:52:39Z")

</div>

> [@DetlevD](#):
>
> But what should bring this expression in an action 'Format Value' on the tag-field TITLE?

My example was part of a larger expression. I tried to use the strstr part basically to determine if a filename contains a given string.

Thanks for hinting to the difference between '0' and "0". Was i supposed to know that? The documentation usually uses double quotes for strings.

---

<div class="post-metadata">

### Author: ![anon40688970](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@anon40688970](https://community.mp3tag.de/u/anon40688970)
#### Post date: [April 30, 2011, 3:55pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/4 "2011-04-30T15:55:11Z")

</div>

> [@anon40688970](#):
>
> Was i supposed to know that? The documentation usually uses double quotes for strings.

Guess thats my fault. I mixed up websources and actions.

Sorry

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [April 30, 2011, 4:20pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/5 "2011-04-30T16:20:00Z")

</div>

> [@anon40688970](#):
>
> Guess thats my fault. I mixed up websources and actions. ...

Never mind, Mp3tag's several scripting languages and their loose syntax are good for more than one recurring confusion.

DD.20110430.2022.CEST

---

<div class="post-metadata">

### Author: ![AndrewGebbie](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@AndrewGebbie](https://community.mp3tag.de/u/AndrewGebbie)
#### Post date: [August 23, 2012, 1:11pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/6 "2012-08-23T13:11:40Z")

</div>

> [@DetlevD](#):
>
> Try it using the correct syntax:
> 
> **$strstr(%\_filename%,'e')**
> 
> Result: 15  
> Filename: Albinoni-Trumpet Concerto

The difference is the space between the parameters:

anon40688970: $strstr(%\_filename%, "e")  
DetlevD: $strstr(%\_filename%,'e')

The second of these works, the first doesn't. Either kind of quote mark is fine

As a programmer I wasn't expecting this and it took me hours to figure it out!

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [August 23, 2012, 1:48pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/7 "2012-08-23T13:48:12Z")

</div>

> [@Andrew Gebbie](#):
>
> Either kind of quote mark is fine

No, double quotes are treated as literals.

$strstr(%\_filename%,e) is another possibility.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [December 28, 2018, 2:30pm UTC](https://community.mp3tag.de/t/strstr-broken-result-is-always-0/11942/8 "2018-12-28T14:30:21Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
