# Problems with dash in scripting functions

**URL:** <https://community.mp3tag.de/t/problems-with-dash-in-scripting-functions/19727>\
**Category:** Support\
**Created:** [January 28, 2018, 7:49am UTC](https://community.mp3tag.de/t/problems-with-dash-in-scripting-functions/19727 "2018-01-28T07:49:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bookworm1632](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@bookworm1632](https://community.mp3tag.de/u/bookworm1632)\
**Post date:** [January 28, 2018, 7:49am UTC](https://community.mp3tag.de/t/problems-with-dash-in-scripting-functions/19727/1 "2018-01-28T07:49:47Z")

</div>

Hi,

I'm trying to perform a fairly simple operation - take a filename which is Artist 1, Artist 2 - Title and populate the Artist field with "Artist 1 || Artist 2"

I'm working using Actions here so that I can easily repeat the operation.  
Originally I split the filename by "-", but ran into an issue with artists like T-Pain, so thought to use the Format Value Action and split on " - " instead. I was going to use $strstr to identify where the split is, $left to take only the Artists and finally $replace to swap commas for ||.

The trouble was it didn't work - $strstr could find "- " and "-", but not " - " in the filename.

Perhaps the first space isn't really a space you think, so I split the operation into 3 separate actions;

1. Copy the filename into a user defined tag
2. Use Replace on the new tag to swap " - " for "x-x"
3. Use the complex operation described above involving $strstr to locate x-x and truncate the string etc.

But now despite 1 & 2 working fine, operation 3 could not locate "x-x". It IS there, and my syntax in 3 is correct because if I swap "x-x" for another 3 character string located in that artist, it works!

So it appears that $strstr has an issue with dashes unless a dash is the first character of the string it is looking for.

---

<div class="post-metadata">

**Author:** ![poster](https://community.mp3tag.de/user_avatar/community.mp3tag.de/poster/32/4881_2.png) [@poster](https://community.mp3tag.de/u/poster)\
**Post date:** [January 28, 2018, 8:30am UTC](https://community.mp3tag.de/t/problems-with-dash-in-scripting-functions/19727/2 "2018-01-28T08:30:01Z")

</div>

Are you sure that it is always the same dash-charcater?  
[https://en.wikipedia.org/wiki/Wikipedia:Hyphens\_and\_dashes](https://en.wikipedia.org/wiki/Wikipedia:Hyphens_and_dashes)

You can easily test this by not writing the dash but c&p it from the source.  
You can also test $strstr() by defining a column with the value $strstr(%\_filename%, - ).

Why are you not using the action-type "Guess Values" to populate the artist-tag directly?

---

<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:** [January 28, 2018, 10:22am UTC](https://community.mp3tag.de/t/problems-with-dash-in-scripting-functions/19727/3 "2018-01-28T10:22:31Z")

</div>

> [@bookworm1632](#):
>
> ... The trouble was it didn't work - $strstr could find "- " and "-", but not " - " in the filename. ... it appears that $strstr has an issue with dashes ...

Try this formatstring ...

**$replace($left('Artist 1, Artist 2 - Title',$sub($strstr('Artist 1, Artist 2 - Title',' - '),1)),', ',' || ',)**

resp.

**$replace($left(%\_filename%,$sub($strstr(%\_filename%,' - '),1)),', ',' || ',)**

If you suspect any dash ambiguity then find there something useful ...  
[/t/16483/1](https://community.mp3tag.de/t/16483/1)  
[/t/15410/1](https://community.mp3tag.de/t/15410/1)

DD.20180128.1250.CET

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [February 9, 2026, 12:27pm UTC](https://community.mp3tag.de/t/problems-with-dash-in-scripting-functions/19727/4 "2026-02-09T12:27:12Z")

</div>


