- 1
- 2
- 3
- 4
- 5
$redir_url = $_conf['www_patch'].str_replace("//////","/",$path[0]);
$redir_url = $_conf['www_patch'].str_replace("/////","/",$path[0]);
$redir_url = $_conf['www_patch'].str_replace("////","/",$path[0]);
$redir_url = $_conf['www_patch'].str_replace("///","/",$path[0]);
$redir_url = $_conf['www_patch'].str_replace("//","/",$path[0]);
i fixed it.
ЗЫ а как бы это сделали функциональщики на хацкале?
Нормализавали бы путь?
http://ideone.com/qo8N0l
Хотя нет, тут нужно придумать что-нибудь с рекурсией.
Держите
В лучших традициях.
Чтобы было похоже, нужно запилить хотя-бы ленивые стримы, чтобы тормозилоработало в константном объёме памяти.
Это и ёжику понятно, потому и рекомендовал ещё и ленивых стримов запилить для смеха.
Не функционально.
teststring = '''\\\\\\asdf\\\\\\fdsasdf\\\\\\\\ f\\\\sad \\\\'''
print(reduce(lambda res, t: res if res and res[-1] == '\\' and t[0] == '\\' else res + t[0], teststring))
teststring = '''\\\\\\asdf\\\\\\fdsasdf\\\\\\\\ f\\\\sad \\\\'''
print(reduce(lambda res, t: res if res and res[-1] == '\\' and t == '\\' else res + t, teststring))