Loading ...
Sorry, an error occurred while loading the content.

[Clip] Re: Replacing comma with a tab

Expand Messages
  • dracorat
    I changed how I formulate regular expressions to not use .* or .+ a long time ago, so I have no examples that come readily to mind, but I do remember the
    Message 1 of 34 , Apr 2, 2008
    • 0 Attachment
      I changed how I formulate regular expressions to not use .* or .+ a
      long time ago, so I have no examples that come readily to mind, but I
      do remember the absolute frustration I used to have over it.

      It's possible it's a matter of education - there could be some way to
      know for sure one way or the other, but I do know that whenever I talk
      to any of my cohorts who use it, they all are similarly confused about
      it, so it's a common problem =/.

      --Keith

      --- In ntb-clips@yahoogroups.com, buralex@... wrote:
      >
      > "dracorat" <dracorat@...> said on Mar 31, 2008 13:22 -0400 (in
      > part):
      > > I never really trust the "." specifier when combined with a * or + as
      > > how it operates tends to be hit-and-miss (sometimes only grabbing the
      > > first thing sometimes grabbing everything it can) and you have to test
      > > to be sure.
      > >
      > > I probably would have gone with something like:
      > >
      > > ^([^,]*),([^,]*),
      > >
      > > $1\t$2\t
      > >
      > > But as long as the other solutions are working then that's cool.
      > > --Keith
      > Keith
      > Can you provide examples of "hit-or-miss" operation of the "."
      specifier?
      >
      > I used to have problems guessing/predicting ;-) what a dot would do
      > but since I got fairly comfortable with ? to make .* non greedy and
      > (?s)/(?-s) to make dot match/not match line feeds I'm not surprised as
      > often :-)
      >
      > Regards ... Alec -- buralex-gmail
      > --
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    • notetab_is_great
      ... inside one ... there ... to work correctly too. That s a strange conclusion to reach as a result of this thread... It is true that the regular expression
      Message 34 of 34 , Apr 5, 2008
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "janderri" <jan_derrick@...> wrote:
        >
        > --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@> wrote:
        > >
        > > Flo wrote:
        > > > "^(.+\t.+?),"
        > >
        > > A question, as I have never yet used such a complicated term
        inside one
        > > pair of parentheses:
        > > What does the non greedy specifier apply to there exactly and would it
        > > make any sense to write (.+?\t.+?) instead? We were never told if
        there
        > > could be preexisting tabs anywhere in the source lines.
        > >
        > > Danke
        > > Axel
        > >
        >
        >
        > I think we can conclude this with :
        >
        > Regular expressions in NoteTab are a mess + we can't even trust them
        to work correctly too.


        That's a strange conclusion to reach as a result of this thread...

        It is true that the regular expression given here was written making
        an assumption that the only tab at the beginning of the data is the
        one that was just inserted by replacing the previous ",". However,
        that doesn't mean that regular expressions are a mess, or don't
        work... it just means there was a poor assumption made in constructing
        this one.

        Thing is, regular expressions are used to tackle problems that are
        hard to solve in other ways, and that doesn't mean those problems are
        easily solved using regular expressions, either... but often they are
        solvable.

        While there are many smart people contributing to this forum, many of
        the problems they are attempting to help with are poorly specified.

        Even this regular expression is correct, if the assumption made
        actually holds; it is unfortunate that assumptions like that sneak in
        without being stated... that's a problem with assumptions in general,
        though, not just ones regarding regular expressions.
      Your message has been successfully submitted and would be delivered to recipients shortly.