S
S
SOTVM2018-06-11 11:59:12
bash
SOTVM, 2018-06-11 11:59:12

Non-greedy regular expressions in Bash?

Help me please.
Perl is easy

Filmix=$(echo "$source_link" | perl -p -e "s|(^.*?filmix.+?)/.*$|\1|")

# I need to truncate the URL if
# the protocols are http or https ,(any)
# domain 2-ur. contains filmix (in the pearl example, it ends in filmix, in principle it will do)
# domain 1-ur. any ,
# up to the form protocol://dom2.dom1 / blah blah blah (without a slash at the end
with sed awk I steamed all day, but I didn’t figure out how.
I think it’s not right, for the sake of one expression, (the whole script on bash), drag pearl courts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
x1shn1k, 2018-06-11
@sotvm

Not sure if I understood you correctly, but:

$ echo 'http//fsdfsd.filmix.com/fsdfsdfsdf/dfsdf?q=ffsdfsdfsdf' | grep -o -P '(^.*filmix.+?)(?=/)'
http//fsdfsd.filmix.com

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question