(regexp-match* #px"(AA.+?AA)" str)

regexp-match* matches multiple times through the string.

As with Perl and pcre in general, a trailing '?' makes quantifers
non-greedy.



On Sat, Nov 5, 2016 at 8:59 AM, <meino.cra...@gmx.de> wrote:

> Hi Jens,
>
> thanks for your reply! :)
>
> ...hmmm...I /think/ I understand the mechanism now...but
> if it is as it seems to be...I run into another problem.
>
> Suppose your have a long line of character with groups
> of certain chararcter and random caharcters in between.
>
> Something like this
> SHDKJSHKDAHSKJDHSKAABBBAAAKAJSHDOQWDASLDLAAAMEINOAAJASLAKJDL
> SJDLAAJENSAASJHDKASHDK
>
> The pattern here is AA<a word,no space>AA.
>
> The first idea, which came into my mind would be to match with
> something like
>
> (regex-match rx#"(AA[A-Z]+AA))
>
> (beside the fact, that I currently dont know, how to match non
> greedily): The guide says:
>
>
>         > (regexp-match #rx"([a-z ]+;)*" "lather; rinse; repeat;")
>
>         '("lather; rinse; repeat;" " repeat;")
>
>     Here, the *-quantified subpattern matches three times, but it is the
> last submatch that is returned.
>
> So I would get back AAJENSAA and AAMEINOAA would be matched but not
> included in the list of matched strings.
>
> If the line is of unknown length as the count of "AA<word>AA" groups
> is, I would not know how to cope with this?
>
> Is there any other way to get back a list of all found matches instead
> of only he last one?
>
> Thank you very much in advance for any help!
> Cheers
> Meino
>
>
>
>
> Jens Axel Søgaard <jensaxelsoega...@gmail.com> [16-11-04 20:28]:
> > The first result string is the first matched string. The second result
> is what was matched by the sub expression in the parenthesis.
> >
> >
> > > Den 4. nov. 2016 kl. 20.04 skrev meino.cra...@gmx.de:
> > >
> > > Hi,
> > >
> > > Normally I would tend to think, that I am
> > > quite familiar with regex and their usage
> > > (background: UNIX?Linux, sed, vi/vim, Perl...)
> > >
> > > Then I played a little with regex-match...and
> > > I have to go to school again..,,
> > >
> > > From the Racket guide:
> > >> (regexp-match #rx"([a-z ]+;)*" "lather; rinse; repeat;")
> > > '("lather; rinse; repeat;" " repeat;")
> > >
> > > [a-z ]: matches one lowercase character of the range of a-z and the
> #\space
> > > +     : the above one ore more times
> > > ;     : followed by a ';'
> > > ()    : all the above grouped
> > > *     : 0 or more times
> > > seems obvious..
> > >
> > > But the result is not (at least for me... ;)
> > > '("lather; rinse; repeat;" " repeat;")
> > >
> > > I understand "lather; rinse; repeat;" as match -
> > > it reflects the "greedy behaviour" of regex.
> > >
> > > But " repeat;" ???
> > >
> > > Why not "rinse; repeat;" then???
> > >
> > > I am buffled...<scratching my head>
> > >
> > > (help!)+
> > >
> > > :)
> > >
> > > (Thank you)+ (much)+ in advance!
> > > Cheers
> > > Meino
> > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to