help-bash
[Top][All Lists]
Advanced

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

Re: case $var in $list) issue


From: Zachary Santer
Subject: Re: case $var in $list) issue
Date: Fri, 1 Nov 2024 13:19:38 -0400

On Fri, Nov 1, 2024 at 12:56 PM #!microsuxx <fxmbsw7@gmail.com> wrote:
>
> On Fri, Nov 1, 2024, 17:24 Zachary Santer <zsanter@gmail.com> wrote:
>>
>> IFS='|'
>> if [[ one =~ ${array[*]} ]]; then
>>   printf 'ye\n'
>> fi
>
>
> but enables free regex parsing in arr
>
> a bit further for complicated strings :
> but still needs regex escaping
> maybe replace every char to be inside a [<here>] char class
>
> arr=( a b c ) IFS=\|
> arr=( "${arr[@]/#/^}" ) IFS=$' \t\n'
> [[ one =~ ${arr[*]/%/$} ]]
>
> plus , regex escape

Ah, yes.

IFS='|'
if [[ one =~ ${array[*]//[][}{)(.*?+|'"\]/\\&} ]]; then
  printf 'ye\n'
fi

Your clock cycles are secure.

Wouldn't the same thing apply to the extended pattern matching
operators in your case?



reply via email to

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