[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is wrong with a regex?
From: |
Peng Yu |
Subject: |
Re: What is wrong with a regex? |
Date: |
Fri, 3 Feb 2023 22:10:40 -0600 |
On 2/3/23, Koichi Murase <myoga.murase@gmail.com> wrote:
> 2023年2月4日(土) 12:44 Peng Yu <pengyu.ut@gmail.com>:
>> $ f=row.txt; [[ $f =~ ^row([0-9]*)(\|_x)[.]txt$ ]]; echo $?
>> 1
>
> You need to write (|_x) instead of (\|_x). In the conditional command
> [[ ... ]], the character `|' loses the original meaning of the pipe
> operator, so you can directly specify it without quoting. If you quote
> it as \|, it becomes a regular expression that matches a literal
> single character `|'.
That would be a syntax error as the return status 2 indicates.
$ f=row.txt; [[ $f =~ ^row([0-9]*)(|_x)[.]txt$ ]]; echo $?
2
> $ [[ '|' =~ \| ]]; echo $?
> 0
>
--
Regards,
Peng
- Re: What is wrong with a regex?, (continued)
- Re: What is wrong with a regex?, Koichi Murase, 2023/02/03
- Re: What is wrong with a regex?, Dennis Williamson, 2023/02/03
- Re: What is wrong with a regex?, Leonid Isaev, 2023/02/04
- Re: What is wrong with a regex?, Koichi Murase, 2023/02/04
- Re: What is wrong with a regex?, Koichi Murase, 2023/02/04
- Re: What is wrong with a regex?, Jeffrey Walton, 2023/02/04
- Re: What is wrong with a regex?, Koichi Murase, 2023/02/04
- Re: What is wrong with a regex?, Leonid Isaev, 2023/02/04
Re: What is wrong with a regex?,
Peng Yu <=
- Re: What is wrong with a regex?, Koichi Murase, 2023/02/03
- Re: What is wrong with a regex?, Leonid Isaev (ifax), 2023/02/04
- Re: What is wrong with a regex?, Peng Yu, 2023/02/04
- Re: What is wrong with a regex?, alex xmb ratchev, 2023/02/04
- Re: What is wrong with a regex?, Kerin Millar, 2023/02/04
- Re: What is wrong with a regex?, alex xmb ratchev, 2023/02/04
Re: What is wrong with a regex?, Chet Ramey, 2023/02/06
Re: What is wrong with a regex?, alex xmb ratchev, 2023/02/06
Re: What is wrong with a regex?, Chet Ramey, 2023/02/06
Re: What is wrong with a regex?, alex xmb ratchev, 2023/02/06