If you don't have perl(-compatible) regular expressions available, you can do the match with ordinary egrep. However, you have to figure out the inverse of the terminating expression. For example, if a string terminates just before ..
, then it matches any sequence which does not contain ..
, which means that it matches any character which is not a period, or a period followed by a character which is not a period. That's the same as saying "an optional period followed by a non-period":
$ echo "fwef-$*nVrtmp://Ggdggragravrv.com/lolwtf.mp5skill0rz%%&:/getr4kt..Glub" |
> grep -oE 'rtmp:([.]?[^.])*'
rtmp://Ggdggragravrv.com/lolwtf.mp5skill0rz%%&:/getr4kt
If the terminating string is a single character, that's even easier: just match anything other than the terminator. For example, to match a string up to but not including a ?
:
$ echo "......mp3:mp3/19695c8f0fcbe45521908c3ec60f8f96554a523e?Expires=1421093669&..." |
> grep -oE 'mp3/[^?]*'
mp3/19695c8f0fcbe45521908c3ec60f8f96554a523e