Вы можете захотеть изучить это выражение:
^(.*?)(\s+\/.*)$
Здесь у нас есть две группы захвата, где первая собирает желаемый результат, а вторая - ваш нежелательный шаблон, ограниченный начальным и конечным символами, просто для безопасности, который можно удалить, если вы хотите:
(.*?)(\s+\/.*)
Python Test
# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^(.*?)(\s+\/.*)$"
test_str = ("123 / some text 123\n"
"anything else / some text 123")
subst = "\\1"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
JavaScript Demo
const regex = /^(.*?)(\s+\/.*)$/gm;
const str = `123 / some text 123
anything else / some text 123`;
const subst = `\n$1`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
RegEx
Если это не было вашим желаемым выражением, вы можете изменить / изменить его выражения в regex101.com .

RegEx Circuit
Вы также можете визуализировать свои выражения в jex.im :

Пробелы
Для пробелов перед желаемым выводом мы можем просто добавить группу захвата с негативным видом позади :
^(\s+)?(.*?)(\s+\/.*)$
JavaScript Demo
const regex = /^(\s+)?(.*?)(\s+\/.*)$/gm;
const str = ` 123 / some text 123
anything else / some text 123
123 / some text 123
anything else / some text 123`;
const subst = `$2`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
