awk: error : tent of
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I use the following regex to find email addresses:
echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'
But it returns the error:
awk: cmd. line:1: error : tent of
awk regular-expression email
add a comment |Â
up vote
3
down vote
favorite
I use the following regex to find email addresses:
echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'
But it returns the error:
awk: cmd. line:1: error : tent of
awk regular-expression email
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I use the following regex to find email addresses:
echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'
But it returns the error:
awk: cmd. line:1: error : tent of
awk regular-expression email
I use the following regex to find email addresses:
echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'
But it returns the error:
awk: cmd. line:1: error : tent of
awk regular-expression email
edited Jun 6 at 10:31
Jeff Schaller
30.9k846105
30.9k846105
asked Jun 6 at 9:53
sci9
1609
1609
add a comment |Â
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
2
down vote
accepted
Short version, use this:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
Assuming the actual error message is something like:
awk: cmd. line:1: error: Invalid range end: â¦
Then, there are 4 issues in your line:
The dash (
-
) means "character range" not an explicit dash.The reason for the error message is that the two characters surrounding the dash (
-
) inside the character range (_
and.
) are not in (ASCII) order. The character range.-_
raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot.
and an underscore_
), but to match an explicit dash (-
).To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either
[-â¦]
,[â¦-]
. Or, discouraged, escape it-
. That is, both of these work:[-a-zA-Z0-9_.+]
[a-zA-Z0-9_.+-]But no, a backslash is not a general solution to make a dash explicit. Try:
$ echo 'ab-cd' | grep -Eo '[a-c]+'
ab
cThe grep regex (even if extended:
-E
) does not match the dash.The
+
is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:^([-a-zA-Z0-9_.+]+)@
A dot
.
is an special character that "match any character except newline".
As such, you need to either escape it.
or use a "bracket expression"[.]
to explicitly match a dot character, use this:^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).
And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:
([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$
But you are probably using GNU awk, and the correct syntax should then be:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
add a comment |Â
up vote
2
down vote
Answer:
echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
name@server.com
Explanation:
The character -
is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.
Further info:
Check your regexes on this useful website when in doubt.
As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: .
represents any character, and you should escape it if you want it to mean a literal dot .
Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to +
in the first character set, and I have to thank Isaac again for spotting this!
One more thing that is beyond me is why you would use all those round brackets ()
.
Apart from correcting the use of -
and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.
Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
â Kusalananda
Jun 6 at 15:27
The dot (.
) should be escaped. The plus (+
) needs no escaping.
â Isaac
Jun 6 at 21:00
@Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
â Isaac
Jun 6 at 21:27
@Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
â simlev
Jun 8 at 9:10
add a comment |Â
up vote
1
down vote
The hyphen -
is special character in character class (Bracket Expression) which specifying the character range. If you want add literal -
into your character class you will need to either escape it or move it to the end or beginning (after the ^
, if any) of your character class.
[a-z-]
[-a-z]
[a-z-A-Z]
7.[...]
The < hyphen-minus > character shall be treated as itself if it occurs
first (after an initial^
, if any) or last in the list, or as an
ending range point in a range expression. As examples, the expressions
[-ac]
and[ac-]
are equivalent and match any of the characters
'a', 'c', or '-';[^-ac]
and[^ac-]
are equivalent and match any
characters except 'a', 'c', or '-'; [...]
If a bracket expression specifies both '-' and ']', the ']' shall be
placed first (after the '^', if any) and the '-' last within the
bracket expression.
It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
â Isaac
Jun 6 at 21:06
add a comment |Â
up vote
0
down vote
Which version of awk
are you using?
This command does not error when I use GNU awk
, although it produces no output.
Using solaris
awk
it produces this error:
awk: syntax error near line 1
awk: bailing out near line 1
Reading through your regex
, it's never going to match an email address...
I use GNU Awk 4.1.3 under ubuntu 16.04.
â sci9
Jun 6 at 10:01
"Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
â sci9
Jun 6 at 10:03
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Short version, use this:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
Assuming the actual error message is something like:
awk: cmd. line:1: error: Invalid range end: â¦
Then, there are 4 issues in your line:
The dash (
-
) means "character range" not an explicit dash.The reason for the error message is that the two characters surrounding the dash (
-
) inside the character range (_
and.
) are not in (ASCII) order. The character range.-_
raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot.
and an underscore_
), but to match an explicit dash (-
).To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either
[-â¦]
,[â¦-]
. Or, discouraged, escape it-
. That is, both of these work:[-a-zA-Z0-9_.+]
[a-zA-Z0-9_.+-]But no, a backslash is not a general solution to make a dash explicit. Try:
$ echo 'ab-cd' | grep -Eo '[a-c]+'
ab
cThe grep regex (even if extended:
-E
) does not match the dash.The
+
is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:^([-a-zA-Z0-9_.+]+)@
A dot
.
is an special character that "match any character except newline".
As such, you need to either escape it.
or use a "bracket expression"[.]
to explicitly match a dot character, use this:^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).
And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:
([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$
But you are probably using GNU awk, and the correct syntax should then be:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
add a comment |Â
up vote
2
down vote
accepted
Short version, use this:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
Assuming the actual error message is something like:
awk: cmd. line:1: error: Invalid range end: â¦
Then, there are 4 issues in your line:
The dash (
-
) means "character range" not an explicit dash.The reason for the error message is that the two characters surrounding the dash (
-
) inside the character range (_
and.
) are not in (ASCII) order. The character range.-_
raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot.
and an underscore_
), but to match an explicit dash (-
).To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either
[-â¦]
,[â¦-]
. Or, discouraged, escape it-
. That is, both of these work:[-a-zA-Z0-9_.+]
[a-zA-Z0-9_.+-]But no, a backslash is not a general solution to make a dash explicit. Try:
$ echo 'ab-cd' | grep -Eo '[a-c]+'
ab
cThe grep regex (even if extended:
-E
) does not match the dash.The
+
is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:^([-a-zA-Z0-9_.+]+)@
A dot
.
is an special character that "match any character except newline".
As such, you need to either escape it.
or use a "bracket expression"[.]
to explicitly match a dot character, use this:^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).
And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:
([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$
But you are probably using GNU awk, and the correct syntax should then be:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Short version, use this:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
Assuming the actual error message is something like:
awk: cmd. line:1: error: Invalid range end: â¦
Then, there are 4 issues in your line:
The dash (
-
) means "character range" not an explicit dash.The reason for the error message is that the two characters surrounding the dash (
-
) inside the character range (_
and.
) are not in (ASCII) order. The character range.-_
raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot.
and an underscore_
), but to match an explicit dash (-
).To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either
[-â¦]
,[â¦-]
. Or, discouraged, escape it-
. That is, both of these work:[-a-zA-Z0-9_.+]
[a-zA-Z0-9_.+-]But no, a backslash is not a general solution to make a dash explicit. Try:
$ echo 'ab-cd' | grep -Eo '[a-c]+'
ab
cThe grep regex (even if extended:
-E
) does not match the dash.The
+
is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:^([-a-zA-Z0-9_.+]+)@
A dot
.
is an special character that "match any character except newline".
As such, you need to either escape it.
or use a "bracket expression"[.]
to explicitly match a dot character, use this:^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).
And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:
([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$
But you are probably using GNU awk, and the correct syntax should then be:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
Short version, use this:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
Assuming the actual error message is something like:
awk: cmd. line:1: error: Invalid range end: â¦
Then, there are 4 issues in your line:
The dash (
-
) means "character range" not an explicit dash.The reason for the error message is that the two characters surrounding the dash (
-
) inside the character range (_
and.
) are not in (ASCII) order. The character range.-_
raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot.
and an underscore_
), but to match an explicit dash (-
).To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either
[-â¦]
,[â¦-]
. Or, discouraged, escape it-
. That is, both of these work:[-a-zA-Z0-9_.+]
[a-zA-Z0-9_.+-]But no, a backslash is not a general solution to make a dash explicit. Try:
$ echo 'ab-cd' | grep -Eo '[a-c]+'
ab
cThe grep regex (even if extended:
-E
) does not match the dash.The
+
is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:^([-a-zA-Z0-9_.+]+)@
A dot
.
is an special character that "match any character except newline".
As such, you need to either escape it.
or use a "bracket expression"[.]
to explicitly match a dot character, use this:^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).
And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:
([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$
But you are probably using GNU awk, and the correct syntax should then be:
$ echo "name@server.com" |
> gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'
answered Jun 6 at 20:56
Isaac
6,3041632
6,3041632
add a comment |Â
add a comment |Â
up vote
2
down vote
Answer:
echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
name@server.com
Explanation:
The character -
is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.
Further info:
Check your regexes on this useful website when in doubt.
As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: .
represents any character, and you should escape it if you want it to mean a literal dot .
Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to +
in the first character set, and I have to thank Isaac again for spotting this!
One more thing that is beyond me is why you would use all those round brackets ()
.
Apart from correcting the use of -
and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.
Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
â Kusalananda
Jun 6 at 15:27
The dot (.
) should be escaped. The plus (+
) needs no escaping.
â Isaac
Jun 6 at 21:00
@Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
â Isaac
Jun 6 at 21:27
@Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
â simlev
Jun 8 at 9:10
add a comment |Â
up vote
2
down vote
Answer:
echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
name@server.com
Explanation:
The character -
is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.
Further info:
Check your regexes on this useful website when in doubt.
As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: .
represents any character, and you should escape it if you want it to mean a literal dot .
Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to +
in the first character set, and I have to thank Isaac again for spotting this!
One more thing that is beyond me is why you would use all those round brackets ()
.
Apart from correcting the use of -
and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.
Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
â Kusalananda
Jun 6 at 15:27
The dot (.
) should be escaped. The plus (+
) needs no escaping.
â Isaac
Jun 6 at 21:00
@Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
â Isaac
Jun 6 at 21:27
@Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
â simlev
Jun 8 at 9:10
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Answer:
echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
name@server.com
Explanation:
The character -
is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.
Further info:
Check your regexes on this useful website when in doubt.
As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: .
represents any character, and you should escape it if you want it to mean a literal dot .
Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to +
in the first character set, and I have to thank Isaac again for spotting this!
One more thing that is beyond me is why you would use all those round brackets ()
.
Apart from correcting the use of -
and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.
Answer:
echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
name@server.com
Explanation:
The character -
is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.
Further info:
Check your regexes on this useful website when in doubt.
As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: .
represents any character, and you should escape it if you want it to mean a literal dot .
Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to +
in the first character set, and I have to thank Isaac again for spotting this!
One more thing that is beyond me is why you would use all those round brackets ()
.
Apart from correcting the use of -
and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.
edited Jun 7 at 10:16
answered Jun 6 at 10:18
simlev
47019
47019
Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
â Kusalananda
Jun 6 at 15:27
The dot (.
) should be escaped. The plus (+
) needs no escaping.
â Isaac
Jun 6 at 21:00
@Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
â Isaac
Jun 6 at 21:27
@Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
â simlev
Jun 8 at 9:10
add a comment |Â
Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
â Kusalananda
Jun 6 at 15:27
The dot (.
) should be escaped. The plus (+
) needs no escaping.
â Isaac
Jun 6 at 21:00
@Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
â Isaac
Jun 6 at 21:27
@Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
â simlev
Jun 8 at 9:10
Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
â Kusalananda
Jun 6 at 15:27
Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
â Kusalananda
Jun 6 at 15:27
The dot (
.
) should be escaped. The plus (+
) needs no escaping.â Isaac
Jun 6 at 21:00
The dot (
.
) should be escaped. The plus (+
) needs no escaping.â Isaac
Jun 6 at 21:00
@Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
â Isaac
Jun 6 at 21:27
@Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
â Isaac
Jun 6 at 21:27
@Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
â simlev
Jun 8 at 9:10
@Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
â simlev
Jun 8 at 9:10
add a comment |Â
up vote
1
down vote
The hyphen -
is special character in character class (Bracket Expression) which specifying the character range. If you want add literal -
into your character class you will need to either escape it or move it to the end or beginning (after the ^
, if any) of your character class.
[a-z-]
[-a-z]
[a-z-A-Z]
7.[...]
The < hyphen-minus > character shall be treated as itself if it occurs
first (after an initial^
, if any) or last in the list, or as an
ending range point in a range expression. As examples, the expressions
[-ac]
and[ac-]
are equivalent and match any of the characters
'a', 'c', or '-';[^-ac]
and[^ac-]
are equivalent and match any
characters except 'a', 'c', or '-'; [...]
If a bracket expression specifies both '-' and ']', the ']' shall be
placed first (after the '^', if any) and the '-' last within the
bracket expression.
It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
â Isaac
Jun 6 at 21:06
add a comment |Â
up vote
1
down vote
The hyphen -
is special character in character class (Bracket Expression) which specifying the character range. If you want add literal -
into your character class you will need to either escape it or move it to the end or beginning (after the ^
, if any) of your character class.
[a-z-]
[-a-z]
[a-z-A-Z]
7.[...]
The < hyphen-minus > character shall be treated as itself if it occurs
first (after an initial^
, if any) or last in the list, or as an
ending range point in a range expression. As examples, the expressions
[-ac]
and[ac-]
are equivalent and match any of the characters
'a', 'c', or '-';[^-ac]
and[^ac-]
are equivalent and match any
characters except 'a', 'c', or '-'; [...]
If a bracket expression specifies both '-' and ']', the ']' shall be
placed first (after the '^', if any) and the '-' last within the
bracket expression.
It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
â Isaac
Jun 6 at 21:06
add a comment |Â
up vote
1
down vote
up vote
1
down vote
The hyphen -
is special character in character class (Bracket Expression) which specifying the character range. If you want add literal -
into your character class you will need to either escape it or move it to the end or beginning (after the ^
, if any) of your character class.
[a-z-]
[-a-z]
[a-z-A-Z]
7.[...]
The < hyphen-minus > character shall be treated as itself if it occurs
first (after an initial^
, if any) or last in the list, or as an
ending range point in a range expression. As examples, the expressions
[-ac]
and[ac-]
are equivalent and match any of the characters
'a', 'c', or '-';[^-ac]
and[^ac-]
are equivalent and match any
characters except 'a', 'c', or '-'; [...]
If a bracket expression specifies both '-' and ']', the ']' shall be
placed first (after the '^', if any) and the '-' last within the
bracket expression.
The hyphen -
is special character in character class (Bracket Expression) which specifying the character range. If you want add literal -
into your character class you will need to either escape it or move it to the end or beginning (after the ^
, if any) of your character class.
[a-z-]
[-a-z]
[a-z-A-Z]
7.[...]
The < hyphen-minus > character shall be treated as itself if it occurs
first (after an initial^
, if any) or last in the list, or as an
ending range point in a range expression. As examples, the expressions
[-ac]
and[ac-]
are equivalent and match any of the characters
'a', 'c', or '-';[^-ac]
and[^ac-]
are equivalent and match any
characters except 'a', 'c', or '-'; [...]
If a bracket expression specifies both '-' and ']', the ']' shall be
placed first (after the '^', if any) and the '-' last within the
bracket expression.
edited Jun 6 at 15:06
answered Jun 6 at 10:34
ñÃÂsýù÷
14.7k82361
14.7k82361
It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
â Isaac
Jun 6 at 21:06
add a comment |Â
It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
â Isaac
Jun 6 at 21:06
It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
â Isaac
Jun 6 at 21:06
It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
â Isaac
Jun 6 at 21:06
add a comment |Â
up vote
0
down vote
Which version of awk
are you using?
This command does not error when I use GNU awk
, although it produces no output.
Using solaris
awk
it produces this error:
awk: syntax error near line 1
awk: bailing out near line 1
Reading through your regex
, it's never going to match an email address...
I use GNU Awk 4.1.3 under ubuntu 16.04.
â sci9
Jun 6 at 10:01
"Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
â sci9
Jun 6 at 10:03
add a comment |Â
up vote
0
down vote
Which version of awk
are you using?
This command does not error when I use GNU awk
, although it produces no output.
Using solaris
awk
it produces this error:
awk: syntax error near line 1
awk: bailing out near line 1
Reading through your regex
, it's never going to match an email address...
I use GNU Awk 4.1.3 under ubuntu 16.04.
â sci9
Jun 6 at 10:01
"Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
â sci9
Jun 6 at 10:03
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Which version of awk
are you using?
This command does not error when I use GNU awk
, although it produces no output.
Using solaris
awk
it produces this error:
awk: syntax error near line 1
awk: bailing out near line 1
Reading through your regex
, it's never going to match an email address...
Which version of awk
are you using?
This command does not error when I use GNU awk
, although it produces no output.
Using solaris
awk
it produces this error:
awk: syntax error near line 1
awk: bailing out near line 1
Reading through your regex
, it's never going to match an email address...
edited Jun 6 at 10:01
answered Jun 6 at 9:59
rusty shackleford
1,135115
1,135115
I use GNU Awk 4.1.3 under ubuntu 16.04.
â sci9
Jun 6 at 10:01
"Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
â sci9
Jun 6 at 10:03
add a comment |Â
I use GNU Awk 4.1.3 under ubuntu 16.04.
â sci9
Jun 6 at 10:01
"Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
â sci9
Jun 6 at 10:03
I use GNU Awk 4.1.3 under ubuntu 16.04.
â sci9
Jun 6 at 10:01
I use GNU Awk 4.1.3 under ubuntu 16.04.
â sci9
Jun 6 at 10:01
"Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
â sci9
Jun 6 at 10:03
"Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
â sci9
Jun 6 at 10:03
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448145%2fawk-error-tent-of%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password