In my bash script I have a variable: 

```
appPath="/Payload/coolApp.app"

```

I want to create a string containing:

```
"build/ios/coolApp/"

```

I figured I could use bash string replacement operator:

```
${string/substring/replacement}

```

Unfortunately I discovered that it doesn't remove forward slashes inside a substring.

Example script:

```
appPath="/Payload/coolApp.app"

appName=${appPath/"/.app"/}
appName=${appPath/"/Payload"/}

echo "build/ios/$appName/"

```

My output becomes this:

```
build/ios//Payload/coolApp.app/

```

**My Question: Why doesn't it remove the forwards slashes?**
NOTE: I am currently running on MacOSX 10.11.6

Testing solution scripts:

```
#!/bin/sh

appPath="/Payload/coolApp.app"

appName=${appPath/"/.app"/}
appName=${appPath/"/Payload"/}
echo "Original:" "build/ios/$appName/"

appName=${appPath/"\/.app"/}
appName=${appPath/"\/Payload"/}
echo "Escape \:" "build/ios/$appName/"

v1="${appPath/\/Payload/build\ios}"
echo "heemayl:" $v1

v2="${appPath##/Payload/}"
v2="build/ios/${appPath%.app}/"
echo "redneb:" $v2

```

Output:

```
Original: build/ios//Payload/coolApp.app/
Escape \: build/ios//Payload/coolApp.app/
heemayl: build/ios/coolApp.app
redneb: build/ios//Payload/coolApp/

```