Re: How to match new line with regexp:match ?

Pascal Bourguignon <[email protected]> Fri, 20 Jul 2018 13:41:05 +0200
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>

> On 20 Jul 2018, at 12:02, Jean Louis <[email protected]> wrote:
> 
> Hello,
> 
> I would like to match a new line with
> 
> (regexp:match "?" "text with new lines")
> 
> How does it work?

The regexp module actually uses the standard unix libregex library.

man 3 regex
man 7 re_format

^ and $ will matching beginning and end of lines.

[11]> (regexp:match "^bar"  "foo bar
bar bar
baz bar" :newline t)
#S(REGEXP:MATCH :START 8 :END 11)
[12]> 


[23]> (regexp:match "bar$"  "foo bar
bar bar
baz bar" :newline t)
#S(REGEXP:MATCH :START 4 :END 7)
[24]> 

Otherwise if you want to match the newline itself, just use it in the regexp:


[33]> (regexp:match "
"  "foo bar
bar bar
baz bar")
#S(REGEXP:MATCH :START 7 :END 8)
[34]> 


> 
> -- 
> Jean Louis
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> clisp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/clisp-list

-- 
__Pascal J. Bourguignon__




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list