# How to remove everything after comma

**URL:** https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143
**Category:** General Discussion
**Created:** [July 1, 2018, 2:10pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143 "2018-07-01T14:10:18Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 2:10pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/1 "2018-07-01T14:10:18Z")

</div>

i want removed all content after comma find **comma**

like artist name have  
**Shashwat Singh, Poorvi Koutish**  
i wants  
just this **Shashwat Singh**

please help me thanks

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 1, 2018, 2:20pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/2 "2018-07-01T14:20:02Z")

</div>

You could try an action of the type "Replace with regular expression"  
Search string: `,.*$`  
Replace string:  
(leave empty)  
or an action of the type "Guess value"  
Source: %artist%  
Target: %artist%, %dummy%

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 2:30pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/3 "2018-07-01T14:30:19Z")

</div>

here is the code i am trying to export this `<a href="domain.com/singers/$lower($replace(%artist%, ,-))">%artist%</a>`  
how to removed everything after comma find

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 2:40pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/4 "2018-07-01T14:40:07Z")

</div>

> [@ohrenkino](#):
>
> ,.\*$

i dont wants just comma removed All Character after comma

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 1, 2018, 2:43pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/5 "2018-07-01T14:43:17Z")

</div>

see the help on the correct syntax for scripting expressions:

> **[Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/#string-functions)**
>
> Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

> **[Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/#string-functions)**
>
> Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

I do not see the place where you want to remove everything following the comma.  
The $replace() statement that you use replaces a blank with a hyphen.

To deal with a pattern, you would have to use a regular expression, or the $regexp() function in scripting, e.g.  
`$regexp(%artist%,',.*$',)`

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 1, 2018, 2:46pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/6 "2018-07-01T14:46:03Z")

</div>

> [@swarup](#):
>
> i dont wants just comma removed All Character after comma

Would you please try it first?

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 3:02pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/7 "2018-07-01T15:02:22Z")

</div>

$regexp(%artist%,',.\*$',) its work but now how replace space to - this ?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 1, 2018, 3:29pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/8 "2018-07-01T15:29:57Z")

</div>

you can use them as nested expressions:  
`$replace($regexp(%artist%,',.*$',),' ',-)`

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 5:37pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/9 "2018-07-01T17:37:56Z")

</div>

great thank you

if i want to cut before coma all text how gonna work this ?  
like Shashwat Singh, Poorvi Koutish  
to  
just this Poorvi Koutish

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 1, 2018, 5:42pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/10 "2018-07-01T17:42:56Z")

</div>

> [@swarup](#):
>
> Shashwat Singh, Poorvi Koutish

like this:  
`$regexp('Shashwat Singh, Poorvi Koutish','.*, ',)`

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 6:03pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/11 "2018-07-01T18:03:01Z")

</div>

how to use if function there ? its possbily ?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 1, 2018, 6:12pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/12 "2018-07-01T18:12:18Z")

</div>

> [@swarup](#):
>
> how to is if function there ?

This is a very general question.  
have a look at the links I provided a couple of posts above.  
You will find  
$If  
$eql  
etc.  
so if you want to do a comparison "if artist equals this, then do a) else do b)"  
it would look like this  
$if($eql(%artist%,%composer%),a,b)  
set whatever you want to be done instead of "a" and instead of "b"

But It may be easier to use filters and so first treat the "a" cases and then the "b" cases"

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 6:49pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/13 "2018-07-01T18:49:40Z")

</div>

> [@ohrenkino](#):
>
> $if($eql(%artist%,%composer%),a,b)

`$lower($replace($regexp(%artist%,'.*, ',),' ',-))`  
this will gentore after comma  
now i wants if dont have comma its will empty

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 1, 2018, 7:02pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/14 "2018-07-01T19:02:48Z")

</div>

> [@swarup](#):
>
> this will gentore after comma

Sorry, now I am a little lost what you mean  
and also what you want.

Is it that you want to check if there is a comma and if so: do it.  
And if there is no comma: do not do anything except replace space with hyphen?

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 7:13pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/15 "2018-07-01T19:13:07Z")

</div>

if dont have comma (2nd artist) all code will be empty  
`<a href="domain.com/singers/$lower($replace($regexp(%artist%,'.*, ',),' ',-))">$regexp(%artist%,'.*, ',)</a>`  
default displaying 1st artist if dont have 2nd artist

---

<div class="post-metadata">

### Author: ![swarup](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/258eb7/32.png) [@swarup](https://community.mp3tag.de/u/swarup)
#### Post date: [July 1, 2018, 7:21pm UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/16 "2018-07-01T19:21:15Z")

</div>

Artist name: `<a href="domain.com//singers/$lower($replace($regexp(%artist%,',.*$',),' ',-))">$regexp(%artist%,',.*$',)</a>, <a href="domain.com/singers/$lower($replace($regexp(%artist%,'.*, ',),' ',-))">$regexp(%artist%,'.*, ',)</a>`  
if i have one artist name its showing dublicket if have 2 two artist name that's fine

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 2, 2018, 5:13am UTC](https://community.mp3tag.de/t/how-to-remove-everything-after-comma/42143/17 "2018-07-02T05:13:00Z")

</div>

> [@swarup](#):
>
> if i have one artist name its showing dublicket if have 2 two artist name that's fine

Yes, this is the way the regular expression function works: if there is no hit for the pattern, then you get the source string back.  
As I said: filtering would be an option.
