RosettaCodeData/Task/String-matching/Sed/string-matching.sed

12 lines
308 B
Sed
Raw Permalink Normal View History

2026-04-30 12:34:36 -04:00
# 1. Determining if the first string starts with the second string:
N;/^\(.*\).*\n\1$/!d;s/\n.*//
# 2. Determining if the first string contains the second string at any location:
N;/.*\(.*\).*\n\1$/!d;s/\n.*//
# 3. Determining if the first string ends with the second string:
N;/\(.*\)\n\1$/!d;s/\n.*//