Question: Input:

```
blahŤfoobar1Ťblah

```

Desired output:

```
foobar1

```

I want to get the text between two "Ť" characters.

Assume there will always be either 0 or 2 "Ť" characters, to make things easier.

I tried the following, but I don't know how to get it to know which occurrence it is:

```
echo "blahŤfoobar1Ťblah" | sed -n '/Ť/,/Ť/p'

```

Answer: 
Using `sed`

```
echo "blahŤfoobar1Ťblah" | sed  -r 's/(^.*Ť)(.*)(Ť.*$)/\2/'

```

output

```
foobar1

```

Another possible way using `sed`

```
echo "blahŤfoobar1Ťblah" | sed -r 's/.*Ť(.*)Ť.*/\1/' 

```

output

```
foobar1

```

*Thanks for @kos for the `-r` note*
You can also use `perl` to extract the text:

```
$ echo 'blahŤfoobar1Ťblah' | perl -FŤ -ane 'print"$F[1]\n"'
foobar1

```

Here the key is to use the `-F` option to set the delimiter.

Another approach using a regular expression:

```
$ echo "blahŤfoobar1Ťblah" | perl -pe 's/.*Ť(.*)Ť.*/$1/' 
foobar1

```