It is necessary to write a regular list that looks for tags of the form in the xml-nickname
<data_*3 буквы**пробел**какие угодно символы кроме >*>
[UPD] The interpreter is not bash, as mentioned earlier, but ksh
It is necessary to write a regular list that looks for tags of the form in the xml-nickname
<data_*3 буквы**пробел**какие угодно символы кроме >*>
[UPD] The interpreter is not bash, as mentioned earlier, but ksh
On my version of bash, the following routine worked:
if [[ $str =~ \<data_[az]{3}[[:space:]][^\>]*\> ]]
UPD: checked on ksh 93, also works
[:space:]
is just any amount >
- avp^
negation. And if you replace * with + and put behind the space in the test line >
then the test fails, and if any other character passes. so everything works fine - Mike[^\>]*\>
, which means все что угодно, кроме > сколько угодно раз (в т.ч. ни разу), а после этого >
you can simply check in the terminal. In fact, the question is something else - until the end of the line there should not be > . I don’t know how to mark end of line in bash. (in practice, all this is easily solved using grep) - avp<
, data
, 3 letters, space, anything except >
, that is, we are looking for the nearest >
, using the lazy quantifier *?
.
<data_[a-zA-z]{3} .*?>
grep -P
what is the problem to use? - iksuySource: https://ru.stackoverflow.com/questions/508481/
All Articles
if [[ $str =~ <data_[az]{3}\s[^>]+>) ]]
but the interpreter cursed such an entry. sabzh . The quotation in the required result did not lead - I. Smirnov[[:space:]]
. And in general, the information that a regular schedule is required for bash should be indicated directly in the question, because it has its own dialect - Mikesed
will be easier to do this, but just before that a question arose to implement the regular routine that was used inif
. Namely, it seems to me that the problem arises with the use of{ }
, and the attempt to escape the brackets doesn’t really help - I. Smirnov