+ Reply to Thread
Results 1 to 37 of 37

Text manipulation

Hybrid View

  1. #1
    Harlan Grove
    Guest

    Re: Text manipulation

    "Ron Rosenfeld" <ronrosenfeld@nospam.org> wrote...
    ....
    >How about a negative look-behind assertion?
    >
    >=REGEX.MID($A$1,".*?(?<!FP)(K|$)",ROWS($B$2:B2))


    I keep forgetting Longre uses PCRE rather than VBScript regexp syntax. Too
    many regexp varieties.

    That should work for one literal substring in the assertion, but multiple
    options, e.g., ".+?(?<!(FP|XYZ|D))K" [note: it's more efficient to append a
    K to A1 and use a simple K at the end of the regexp than to use (K|$) - to
    me at least that's a clearer indicator that trailing symbols after the last
    K should be included] could cause backtracking problems. Assertions with
    alternation subexpressions with closures (not the case here, but generally)
    can become a big PITA. If there were multiple prohibited sequences, it may
    be more efficient to mask immediately following cut characters and replace
    them in the results. This is the regexp analog to using ancillary cells for
    intermediate calculations rather than single huge formulas in spreadsheets.
    Just as 2 or 3 formulas may recalc more quickly than a single equivalent
    formula, 2 or 3 simpler regexp operations may recalc more quickly than a
    single, more complex one. Assertions may work well in this case, but I tend
    to avoid them when possible myself.



  2. #2
    Ron Rosenfeld
    Guest

    Re: Text manipulation

    On Mon, 2 Jan 2006 14:26:16 -0800, "Harlan Grove" <hrlngrv@aol.com> wrote:

    >"Ron Rosenfeld" <ronrosenfeld@nospam.org> wrote...
    >...
    >>How about a negative look-behind assertion?
    >>
    >>=REGEX.MID($A$1,".*?(?<!FP)(K|$)",ROWS($B$2:B2))

    >
    >I keep forgetting Longre uses PCRE rather than VBScript regexp syntax. Too
    >many regexp varieties.
    >
    >That should work for one literal substring in the assertion, but multiple
    >options, e.g., ".+?(?<!(FP|XYZ|D))K" [note: it's more efficient to append a
    >K to A1 and use a simple K at the end of the regexp than to use (K|$) - to
    >me at least that's a clearer indicator that trailing symbols after the last
    >K should be included] could cause backtracking problems. Assertions with
    >alternation subexpressions with closures (not the case here, but generally)
    >can become a big PITA. If there were multiple prohibited sequences, it may
    >be more efficient to mask immediately following cut characters and replace
    >them in the results. This is the regexp analog to using ancillary cells for
    >intermediate calculations rather than single huge formulas in spreadsheets.
    >Just as 2 or 3 formulas may recalc more quickly than a single equivalent
    >formula, 2 or 3 simpler regexp operations may recalc more quickly than a
    >single, more complex one. Assertions may work well in this case, but I tend
    >to avoid them when possible myself.
    >


    I will need to keep that in mind. Clearly I have insufficient experience with
    regular expressions to have run into some of the issues you have mentioned.

    I will need to think more about the backtracking issues in order to better
    understand what you write. As well as the pros and cons of trying to avoid
    assertions.

    I have been trying to work out some of the questions posed on the NG's you
    referred me to. Educational. Thanks.

    Best wishes and Happy New Year,

    --ron
    --ron

  3. #3
    Harlan Grove
    Guest

    Re: Text manipulation

    Ron Rosenfeld wrote...
    ....
    >I will need to keep that in mind. Clearly I have insufficient experience with
    >regular expressions to have run into some of the issues you have mentioned.
    >
    >I will need to think more about the backtracking issues in order to better
    >understand what you write. As well as the pros and cons of trying to avoid
    >assertions.

    ....

    If you want to get a real grounding in regular expressions, read
    Jeffrey Friedl's book 'Mastering Regular Expressions, 2nd Ed.', ISBN
    0-596-00289-0. Lots of discussion about backtracking and optimizing
    regular expessions.


  4. #4
    Ron Rosenfeld
    Guest

    Re: Text manipulation

    On 2 Jan 2006 19:05:16 -0800, "Harlan Grove" <hrlngrv@aol.com> wrote:

    >Ron Rosenfeld wrote...
    >...
    >>I will need to keep that in mind. Clearly I have insufficient experience with
    >>regular expressions to have run into some of the issues you have mentioned.
    >>
    >>I will need to think more about the backtracking issues in order to better
    >>understand what you write. As well as the pros and cons of trying to avoid
    >>assertions.

    >...
    >
    >If you want to get a real grounding in regular expressions, read
    >Jeffrey Friedl's book 'Mastering Regular Expressions, 2nd Ed.', ISBN
    >0-596-00289-0. Lots of discussion about backtracking and optimizing
    >regular expessions.


    Thanks. Just ordered a copy from Amazon.


    --ron

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1