in reply to String Newline Question
In a regex, $ does not mean "end of string". It means "end of line", which is just before \n or the end of the string (whichever comes first). If you want to match the null string at the end of the string, use \z.
$ behaves like (?=\z|\n).$_ = "foo\n"; /^foo$/; # true /^foo\z/; # false /^foo\n$/; # true /^foo\n\z/; # true
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: String Newline Question
by merlyn (Sage) on Mar 23, 2002 at 22:26 UTC | |
by Juerd (Abbot) on Mar 23, 2002 at 22:30 UTC |