Question: I have filenames in certificate\_name variable, separated by "|". 

```
For example:-
"e1412be6-3486-478a-a768-bc81b7ac40dd.jpg | Hydrangeas.jpg"

```

I want split the filename before | symbol. 

Tried by using the below code, but it is not working. Could anyone please assist on this ?

```
   this.uploadedFiles.map(data => {
      data.certificate_name.substr(0,data.certificate_name.indexOf('|'));
      return data
 })

```

Answer: 
I have used the `split` method which is used to split by given separator parameter. In your case it is Pipe '`|`'. 

```
this.uploadedFiles.map(data => {
    const stringSplitToArray = data.certificate_name;
    const splitted = stringSplitToArray.split('|');
    console.log(splitted[0]);
    data.certificate_name = splitted[0];// need to add this line then only this solution works perfect
    return splitted[0];
});

```

The resultant data will consist of array of string as shown below.

```
splitted[0]= 'e1412be6-3486-478a-a768-bc81b7ac40dd.jpg'
splitted[1]= 'Hydrangeas.jpg'

```

From your question, I believe you want to retrieve only the first file name, I have gone with index 0.

Hope this help !!
```
"e1412be6-3486-478a-a768-bc81b7ac40dd.jpg | Hydrangeas.jpg".split('|')

```