[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[External] : Use the characters "+" and "-" in regular expressions
From: |
steve-humphreys |
Subject: |
[External] : Use the characters "+" and "-" in regular expressions |
Date: |
Thu, 20 May 2021 13:40:23 +0200 |
> Sent: Thursday, May 20, 2021 at 11:31 PM
> From: "Christopher Dimech" <dimech@gmx.com>
> To: steve-humphreys@gmx.com
> Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
> Subject: [External] : Use the characters "+" and "-" in regular expressions
>
> This could be what you need
>
> (string-match "[\s]+ " s)
>
> Matches any white-space character.
That would actually match a sentence, which I don't want.
What I like to match is a string composed only of whitespace.
> > Sent: Thursday, May 20, 2021 at 11:19 PM
> > From: steve-humphreys@gmx.com
> > To: tomas@tuxteam.de
> > Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
> > Subject: Re: [External] : Use the characters "+" and "-" in regular
> > expressions
> >
> > This is a string of blanks, a string composed of whitespace of any length.
> >
> > " "
> >
> >
> >
> > > Sent: Thursday, May 20, 2021 at 10:50 PM
> > > From: tomas@tuxteam.de
> > > To: steve-humphreys@gmx.com
> > > Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
> > > Subject: Re: [External] : Use the characters "+" and "-" in regular
> > > expressions
> > >
> > > On Thu, May 20, 2021 at 12:37:17PM +0200, steve-humphreys@gmx.com wrote:
> > >
> > > [...]
> > >
> > > > Done some tests and got some strange results that thought would not
> > > > match. Then things
> > > > made more sense after your clarification because when I looked at some
> > > > of the strings,
> > > > there was a comma in them.
> > >
> > > OK. Glad I could help.
> > >
> > > > Am seeing how to match strings of blank lines
> > >
> > > What is "a string of blank lines"?
> > >
> > > I know strings of characters. But a line is not a character.
> > >
> > > Do you mean "several blank lines next to each other"? I don't
> > > think so. But what do you mean?
> > >
> > > > But " +" does not do the job.
> > >
> > > Again: you know by now that this will match "one or more spaces". Is
> > > that for you a "string of blanks" (huh: where did you leave the
> > > "line" from above?) or not?
> > >
> > > > I know why, but how can one match strings of blanks?
> > >
> > > To even have a chance to do that, you'll have to get hold of a more
> > > or less precise idea of what "a string of blanks" is. This is work.
> > >
> > > Begin with:
> > >
> > > (string-match " +" "A summer full of butterflies")
> > > => 1
> > >
> > > Bingo: the first run of one-or-more spaces is at the position 1
> > > (the first position in the string is 0, the "A"). So it's working
> > > as it should.
> > >
> > > So what is /your/ idea of "a string of blank lines" or "a string
> > > of blanks"? Only you can find out.
> > >
> > > If you feel you are stuck in that task, it sometimes help to collect
> > > a couple of examples and counter-examples (they'll come in handy
> > > when you try to test your attempts).
> > >
> > > Cheers
> > > - t
> > >
> >
> >
>
>
- [External] : Use the characters "+" and "-" in regular expressions, (continued)
- [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, tomas, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, tomas, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, tomas, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, tomas, 2021/05/20
- [External] : Use the characters "+" and "-" in regular expressions, Christopher Dimech, 2021/05/20
- [External] : Use the characters "+" and "-" in regular expressions,
steve-humphreys <=
- [External] : Use the characters "+" and "-" in regular expressions, Christopher Dimech, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, tomas, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Yuri Khan, 2021/05/20
- [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20