# Basic help using "replace"

**URL:** <https://discuss.hail.is/t/basic-help-using-replace/1274>\
**Category:** Hail Query & hailctl\
**Created:** [February 5, 2020, 7:01pm UTC](https://discuss.hail.is/t/basic-help-using-replace/1274 "2020-02-05T19:01:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mark](https://discuss.hail.is/u/Mark)\
**Post date:** [February 5, 2020, 7:01pm UTC](https://discuss.hail.is/t/basic-help-using-replace/1274/1 "2020-02-05T19:01:37Z")

</div>

Apologies for my coding ignorance. I have a VCF file with identifiers such as “R01C01-1012345” or “R33C44-1234567”. I’d like to trim off the first 6 characters and the hyphen, leaving me with identifiers “1012345” and “1234567”. I’m trying to use the “replace” function, but I keep struggling with the syntax. How would you write this efficiently? Thanks!

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [February 5, 2020, 7:02pm UTC](https://discuss.hail.is/t/basic-help-using-replace/1274/2 "2020-02-05T19:02:45Z")

</div>

If they always are delimited by a dash like this, you could do: `id.split('-')[1]`

---

<div class="post-metadata">

**Author:** ![Mark](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mark](https://discuss.hail.is/u/Mark)\
**Post date:** [February 5, 2020, 7:06pm UTC](https://discuss.hail.is/t/basic-help-using-replace/1274/3 "2020-02-05T19:06:30Z")

</div>

Thanks. That does what I want to accomplish, but how can I incorporate the change into my matrix table ‘d’ with identifier field ‘s’. I tried the following:

‘’’  
d.s = d.s.split(’-’)[1]  
‘’’

It said that the matrix table is “not mutable”.

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [February 5, 2020, 7:08pm UTC](https://discuss.hail.is/t/basic-help-using-replace/1274/4 "2020-02-05T19:08:03Z")

</div>

Hail’s interfaces are “functional” not mutable, so you’ll need to use a method like annotate/select/key\_by to change fields. In this case:

```auto
mt = mt.key_cols_by(s = mt.s.split('-')[1]

```

---

<div class="post-metadata">

**Author:** ![Mark](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mark](https://discuss.hail.is/u/Mark)\
**Post date:** [February 5, 2020, 7:09pm UTC](https://discuss.hail.is/t/basic-help-using-replace/1274/5 "2020-02-05T19:09:55Z")

</div>

That seems to work!
