A strange treatment of EOL symbol in Regular Expressions.

Product Compare Forums Multi-Edit Support A strange treatment of EOL symbol in Regular Expressions.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #764
    Anonymous
    Inactive

    Hi,

    I noticed a strange behaviour of the RE when the End of Line symbol (EOL) presents in the text to be matched. The EOL kind of stops the search.
    There will be no match in following sample text when searched with this RE sequence in UNIX style “Line1[^3]*3”.

    Line1
    Line2
    Line3

    However, the RE sequence, which specifies all EOL symbols explicitly, produces a match.
    “Line1$[^3]*$[^3]*3”.

    In my understanding the [^X] sequence should match any character except for ‘X’, which includes the “EOL” symbol.
    I checked is with other text editor and it behaved nicely. I hope, it’s not a big deal to take care of this issue.

    #3025
    ReidSweatman
    Participant

    The existing regex engine doesn’t implement Posix or PERL-style regular expressions. You’re correct that the regex without the explicit EOL marker will not match across lines as you expect. The regex engine will be brought to PERL-standard in a future release.

    For now, the workaround for such multi-line searches is a pattern such as
    [code:15mtc40y](.@$.@)@.@[/code:15mtc40y]
    Create an alias for it called, say, <ml>. Then you can do searches like this:
    [code:15mtc40y]Line1<ml>3[/code:15mtc40y]
    which will work across lines.

    #3026
    Anonymous
    Inactive

    Thanks, Reid. It’s a nice workaround. Looking forward for the Perl-standard compatibility :)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.