s is the substitution operator. Typically, the delimiter uses '/':
s/foo/bar/
but this is not required: instead, several other characters can be used as delimiters. In this case, '!' was used as a delimiter, apparently to avoid having to avoid the "/" characters in the actual text to be replaced.
In your particular case, the first line removes the text match '. +? '; those. removes foo tags with or without content.
The second line replaces everything with ';' characters with the characters "/", globally (all occurrences).
The python equivalent uses the re module:
f=re.sub(searchregx,replacement_str,line)
source share