# How to use string(strip..) function?

**URL:** https://discourse.cmake.org/t/how-to-use-string-strip-function/1872
**Category:** Code
**Created:** [September 21, 2020, 4:53pm UTC](https://discourse.cmake.org/t/how-to-use-string-strip-function/1872 "2020-09-21T16:53:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![swoo.quek](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@swoo.quek](https://discourse.cmake.org/u/swoo.quek)
#### Post date: [September 21, 2020, 4:53pm UTC](https://discourse.cmake.org/t/how-to-use-string-strip-function/1872/1 "2020-09-21T16:53:14Z")

</div>

I have the following strings:  
S1 = “C:/myfolder/abc/myfile.txt”  
S2 = “C:/myfolder”

I want to use string() function such that:  
S3 = “/abc/myfile.txt”, ie. (S3 = S1 - S2)

How can I do that? Should I use string(strip…)? I don’t know how to use this

---

<div class="post-metadata">

### Author: ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)
#### Post date: [September 22, 2020, 11:37pm UTC](https://discourse.cmake.org/t/how-to-use-string-strip-function/1872/2 "2020-09-22T23:37:53Z")

</div>

`string(STRIP)` removes leading and trailing spaces.

What you want to do seems more related to `string(REPLACE)` or `string(REGEX REPLACE)`.

I hope this helps.
