EOL Anchor under Windows

A

Arifi Koseoglu

Hello people,

Could someone please tell me whether:

1. The $ end-of-line anchor behaves differently in the MS Windows
environment
2. The $ end-of-line anchor does not work in the MS Windows environment
3. I am an ignorant idiot and do not know how to use the $ anchor.

Environment: W2K + cygwin

What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?

TIA,
-arifi
 
G

Gunnar Hjalmarsson

Arifi said:
Could someone please tell me whether:

1. The $ end-of-line anchor behaves differently in the MS Windows
environment
2. The $ end-of-line anchor does not work in the MS Windows environment
3. I am an ignorant idiot and do not know how to use the $ anchor.

It would be suitable if you let us know which programming language you
are referring to, and showed us the code that made you ask that
question. If you don't, I personally tend to believe that 3. is true
and will keep being true.
Environment: W2K + cygwin

What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?

How about deciding which language you are dealing with and post your
question to an appropriate newsgroup for that language only.
 
J

Jeff Schwab

Arifi said:
Hello people,

Could someone please tell me whether:

1. The $ end-of-line anchor behaves differently in the MS Windows
environment
2. The $ end-of-line anchor does not work in the MS Windows environment
3. I am an ignorant idiot and do not know how to use the $ anchor.

I assume you are talking about vim.

1) Make sure you compiled vim to recognize CR-LF line termination.
2) :set list
3) :set listchars=eol:$
Environment: W2K + cygwin

What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?

One character of punctuation, followed by three alphanumeric characters.
The meanings of the named character classes depend on locale and encoding.
 
A

Arifi Koseoglu

Jeff said:
One character of punctuation, followed by three alphanumeric
characters. The meanings of the named character classes depend on
locale and encoding.

Thanks Jeff.. What do you say about the $ at the end of the regex - should
it not cause this regex to match only (and always) at the ends of lines?


As to Gunnar Hjalmarsson's comments

I am *not* using any language, just plain egrep in a bash shell.
The reason I selected these newsgroups is that these seem to be the
ones where there is discussion is going on regular expressions.

Best,
-arifi
 
J

Jeff Schwab

Arifi said:
What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?
One character of punctuation, followed by three alphanumeric
characters. The meanings of the named character classes depend on
locale and encoding.

Thanks Jeff.. What do you say about the $ at the end of the regex - should
it not cause this regex to match only (and always) at the ends of lines?

Yes, sorry I missed that.
 
A

Arifi Koseoglu

Jeff Schwab said:
grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'
Thanks Jeff.. What do you say about the $ at the end of the regex - should
it not cause this regex to match only (and always) at the ends of lines?

Yes, sorry I missed that.

Well, but it does not. The moment I put the $ to the end, it does not match
anything,
although the all matches without the $ are at EOL.

???
 
G

gnari

[question about $ anchor with grep]
Environment: W2K + cygwin

without having experience with cygwin, may i nevertheless suggest
that your problem is that your lines are terminated with \r\n, but the grep
assumes \n.

in that case your options may be to choose one of:
a) replace the grep command with a perl commandline
b) remove \r from the file befor the grep
c) change the regex to end with '.$' instead of '$'
d) use the -P option with grep, which will allow to use '\r$'

gnari
 
T

Ted Davis

Thanks Jeff.. What do you say about the $ at the end of the regex - should
it not cause this regex to match only (and always) at the ends of lines?


As to Gunnar Hjalmarsson's comments

I am *not* using any language, just plain egrep in a bash shell.
The reason I selected these newsgroups is that these seem to be the
ones where there is discussion is going on regular expressions.

If you are not using a programming language, then posting to a
programming group is improper. Since the message has nothing to do
with awk or Perl, posting to those groups is also improper.

You are unnecessarily antagonizing people who are reading the message
in those groups and are trying to make some sense out of it, but can't
because you cross posted to groups that have nothing to do with the
subject.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my .sig in the body)
 
A

Arifi Koseoglu

I see.

I will really appreciate if you inform me on what group to consult for
issues on regular expressions.

On the other hand, to summarize today:

1. awk and perl do not have anything to do with regular expressions.
2. regular expressions are not related to programming
3. gnu.utils.help group does not have anything to do with the behavior of
gnu grep.

ok...

Thanks for the information.


Ted Davis said:
If you are not using a programming language, then posting to a
programming group is improper. Since the message has nothing to do
with awk or Perl, posting to those groups is also improper.

You are unnecessarily antagonizing people who are reading the message
in those groups and are trying to make some sense out of it, but can't
because you cross posted to groups that have nothing to do with the
subject.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my
..sig in the body)
 
A

Arifi Koseoglu

Thanks gnari, really appreciated.


gnari said:
[question about $ anchor with grep]
Environment: W2K + cygwin

without having experience with cygwin, may i nevertheless suggest
that your problem is that your lines are terminated with \r\n, but the grep
assumes \n.

in that case your options may be to choose one of:
a) replace the grep command with a perl commandline
b) remove \r from the file befor the grep
c) change the regex to end with '.$' instead of '$'
d) use the -P option with grep, which will allow to use '\r$'

gnari
 
T

Tad McClellan

Arifi Koseoglu said:


I don't think you do.

I will really appreciate if you inform me on what group to consult for
issues on regular expressions.


That depends on which dialect of regular expressions you are using.

awk's are different from Perl's. Perl's are different from grep(1)'s. etc...

It doesn't help to solve your problem if the solution involves
a dialect that you are not using.

On the other hand, to summarize today:

1. awk and perl do not have anything to do with regular expressions.


Yes they do, and nobody said that they didn't.

It is your _question_ that has nothing to do with the regular expressions
used by awk or Perl.

You seem to have a question about some version of grep that runs
on Windows. grep is not awk. grep is not Perl.

2. regular expressions are not related to programming


You are making stuff up, or I missed where someone has said that.

_You_ said you are not using any language. (but you are. you are
using some regular expression language or other...)

3. gnu.utils.help group does not have anything to do with the behavior of
gnu grep.


You are making more stuff up, or I missed where someone has said that too.

I saw no followups mentioning gnu.utils.help.

Thanks for the information.


Uh huh.


[ snip foolish TOFU ]
 
A

Arifi Koseoglu

OK.

Cheers!


Tad McClellan said:
Arifi Koseoglu said:


I don't think you do.

I will really appreciate if you inform me on what group to consult for
issues on regular expressions.


That depends on which dialect of regular expressions you are using.

awk's are different from Perl's. Perl's are different from grep(1)'s. etc...

It doesn't help to solve your problem if the solution involves
a dialect that you are not using.

On the other hand, to summarize today:

1. awk and perl do not have anything to do with regular expressions.


Yes they do, and nobody said that they didn't.

It is your _question_ that has nothing to do with the regular expressions
used by awk or Perl.

You seem to have a question about some version of grep that runs
on Windows. grep is not awk. grep is not Perl.

2. regular expressions are not related to programming


You are making stuff up, or I missed where someone has said that.

_You_ said you are not using any language. (but you are. you are
using some regular expression language or other...)

3. gnu.utils.help group does not have anything to do with the behavior of
gnu grep.


You are making more stuff up, or I missed where someone has said that too.

I saw no followups mentioning gnu.utils.help.

Thanks for the information.


Uh huh.


[ snip foolish TOFU ]
 
C

CBFalconer

Arifi said:
Thanks gnari, really appreciated.

gnari said:
[question about $ anchor with grep]
Environment: W2K + cygwin

without having experience with cygwin, may i nevertheless
suggest that your problem is that your lines are terminated
with \r\n, but the grep assumes \n.

in that case your options may be to choose one of:
a) replace the grep command with a perl commandline
b) remove \r from the file befor the grep
c) change the regex to end with '.$' instead of '$'
d) use the -P option with grep, which will allow to use '\r$'

Why do people, when presented with an example of a properly
bottom-posted and snipped reply, insist on making silly top-posted
unsnipped useless further replies? It gives one great doubts as
to their ability to learn.
 
G

gnari

[snipped quoted TOFU example]
Why do people, when presented with an example of a properly
bottom-posted and snipped reply, insist on making silly top-posted
unsnipped useless further replies? It gives one great doubts as
to their ability to learn.

it seems to take a while to sink in what we are talking about.
I usually give them the benefit of the doubt a few times before
I get irritated

gnari
 
J

Jürgen Exner

Arifi said:
Could someone please tell me whether:

1. The $ end-of-line anchor behaves differently in the MS Windows
environment
2. The $ end-of-line anchor does not work in the MS Windows
environment
3. I am an ignorant idiot and do not know how to use the $ anchor.

I think 3 is the probable answer in this case.
Unless you can demonstrate with a small self-contained program that $
"doesn't work" nobody is going to believe 1 or 2, because is does "work" for
millions of users.
Environment: W2K + cygwin

I don't use cygwin, maybe is expects Unix style linebreak instead of Windows
style?
What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?

Don't know. It is a syntax error to begin with.
grep BLOCK LIST
grep EXPR,LIST

--extended-regexp is neither a block nor an expression.

jue
 
T

TLOlczyk

What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?

First of all, the guys who responded by slaming you for not specifying
the language are total idiots, don't worry about them. It was clear
from reading the *whole* post exactly what you were asking ( even
in an inappropriate newsgroup ). It actually did you good, because
these guys took themselves out of the running for answering your
questions. In my experience the reply they give is often stupid
precisely because they haven't read your whole post.

Send off. The groups that you asked in seem at least moderately
appropriate. comp.lang.awk seems a bit of a stretch, still not
a bad group to ask a regex question about. comp.lang.perl.misc
given it's reputation, I would not say it is a bad question for that
group. comp.programming, perfect forum, Virtually every modern
PL has a regex library, why's that? For the same reason a regex
question is appropriate here. Certainly more appropriate than
questions about IDEs or such. gnu.utils.help, grep is a gnu util, No?

Given that sometime peoples have questions which do not seem to
fit in an appropriate newsgroup, your choices seemed OK.

Now for the answer to your question.
If "abc" is a matched string, then grep may be trying to match to
the string "abc"$. Regex's are *not standardised* and vary from
implementation to implementation. Many implementations won't
like your :punct:, :alpha: constructs. I've used as delimiters for
grouping (),\(\),\\(\\),\\\\(\\\\). This isn't going to change anytime
soon, since there are literally millions of elisp,awk,sed,perl,...
libraries that use their form of regex, and the users will hound
to death the person that changes it ( better to suggest reducing
Social Security in a seniors home ).

There are other aspects. Someone suggested that there might be
white spaces at thje end. '[[:punct:]]{1}[[:alnum:]]{3}[:white:]*$'
or '[[:punct:]]{1}[[:alnum:]]{3}[ \t]$' should work if that is the
case.

Another suggested that your EOL might not be what grep expects it to
be. I would think that most greps consider the "system" EOL as EOL.
Open the file you are greping in emacs. If it says something like
UNIX in the status line then that may be the case. Otherwise it
probably isn't.


Finally I would create a test file, with text:
"abc$def"
"ghijkl "
"mnopqr"
( spaces are delimiters here ).
Grep for abc, abc$, jkl$,"jkl $","def"
see what kind of results you get.




The reply-to email address is (e-mail address removed).
This is an address I ignore.
To reply via email, remove 2002 and change yahoo to
interaccess,

**
Thaddeus L. Olczyk, PhD

There is a difference between
*thinking* you know something,
and *knowing* you know something.
 
A

Alan J. Flavell

What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?

First of all, the guys who responded by slaming you for not specifying
the language are total idiots,

I'm just a sceptical bystander. I've always found the regulars on
comp.lang.perl.misc to offer sound advice, even when that advice is
"find a better usenet group".
Now for the answer to your question.

<rhetorical>
You have "the" answer?
If "abc" is a matched string, then grep may be trying to match to
the string "abc"$.
Hmmm

Regex's are *not standardised* and vary from
implementation to implementation.

Oh, gosh. Are we surprised?

So maybe the specific situation that the questioner is in would
be an essential key to "the" answer, after all.

[...various woffle amputated...]
Finally I would create a test file, with text:
"abc$def"
"ghijkl "
"mnopqr"
( spaces are delimiters here ).
Grep for abc, abc$, jkl$,"jkl $","def"
see what kind of results you get.

This must be "the" answer, then, at least according to you.

Me, I think I'd go read the applicable documentation.

f'ups proposed. Have fun.
 
A

Anno Siegel

[newsgroups trimmed, irrelevance snipped]
What is

grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'

supposed to match?

What is this, a quiz?

You tell us what you expect it to match and show us an example that
doesn't meet your expectations. Then we can talk.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top