#540 regex line start anchor broken

v1.24
closed-fixed
General (289)
Unknown
5
2014-08-14
2010-08-12
megamic
No

Using stock 0.19.

Using a line start anchor in a regex as part of a find/replace does not seem to work.

E.g.
Find: ^\s\s\s\s
Replace:

Expect: 4 spaces stripped from the start of each line, where they exist.
Result: ALL spaces at the start of every line are removed.

It is a strange bug. Only spaces at the start of a line are removed, but only them - spaces after non-space characters are preserved on each line.

It almost appears as if the find and replace is recursive - it keeps processing the file until it does not find any more matches. I.e. the first pass it strips off 4 spaces, causing another 4 spaces to be at the start of the line during a subsequent pass.

Discussion

  • Nick Treleaven

    Nick Treleaven - 2010-08-12

    > I.e. the first pass it strips off 4 spaces, causing another 4 spaces to be at the start of the line during a subsequent pass.

    You're right, this is what's happening. I'll try to look at improving this sometime later.

     
  • Lex Trotman

    Lex Trotman - 2012-09-13

    This behavior is correct for an iterative search/replace. I don't think it can or should be changed as it would then unexpectedly change the semantics of the ^ regex operator.

    An additional "find all then replace them" operation that met the OP expectations would be a feature request.

     
  • Lex Trotman

    Lex Trotman - 2012-09-13
    • status: open --> pending
     
  • Colomban Wendling

    • status: pending --> closed-fixed
    • assigned_to: Colomban Wendling
    • Found in: --> Unknown
    • Fixed in: --> v1.24
     

Log in to post a comment.