help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trim both prefix and suffix without using intermediate variable


From: Alan D. Salewski
Subject: Re: trim both prefix and suffix without using intermediate variable
Date: Fri, 20 Jan 2023 22:18:58 -0500
User-agent: Mutt/2.0.5 (2021-01-21)

On 2023-01-20 19:22:29, Peng Yu <pengyu.ut@gmail.com> spake thus:
https://stackoverflow.com/questions/40055221/is-there-a-way-to-remove-both-the-prefix-and-suffix-in-one-shot-in-bash-using

I see that it says impossible to trim both a prefix and a suffix from
a string without using an intermediate variable. Is it so?

--
Regards,
Peng


$ BASH_REMATCH='startmiddleend'
$ if [[ $BASH_REMATCH =~ ^start(.*)end$ ]]; then echo ${BASH_REMATCH[1]}; fi
middle


--
a l a n   d.   s a l e w s k i
ads@salewski.email
salewski@att.net
https://github.com/salewski


reply via email to

[Prev in Thread] Current Thread [Next in Thread]