[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regexp with match over multiple lines
From: |
PJ Weisberg |
Subject: |
Re: regexp with match over multiple lines |
Date: |
Thu, 5 May 2011 13:05:29 -0700 |
On Thursday, May 5, 2011, AngusC <anguscomber@gmail.com> wrote:
> and I am using:
> <\1\[CDATA.*^J*>
>
> But it doesn't make any replacement. I used C-q C-j - ie typed those keys
> when entering.
That matches any number of characters that sren't newlines, followed
by any number of newlines, before the '>'. The way to match any
character including newlines was in the first reply you got:
"\\(.\\|\n\\)"
On Thursday, May 5, 2011, AngusC <anguscomber@gmail.com> wrote:
>
>
> Andreas Röhler wrote:
>> (setq startstring "abc")
>> (setq endstring "def")
>>
>> (defun my-start-end-delete ()
>> " "
>> (interactive "*")
>> (let (beg)
>> (while (search-forward startstring nil (quote move) 1)
>> (setq beg (match-beginning 0))
>> (when (search-forward endstring nil (quote move) 1)
>> (delete-region beg (match-end 0))))))
>>
>> abcABCDEFdefAAAAAAAAAA -> AAAAAAAAAA
>>
>>
>
> I am thinking I probably need to learn lisp to have real power. More regex
> would probably help.
Learning lisp isn't a bad thing, but the above code is really an
example of why you should learn regular expressions. There's no
reason the above should have taken more than one line.
--
-PJ
- regexp with match over multiple lines, AngusC, 2011/05/05
- Re: regexp with match over multiple lines, Peter Dyballa, 2011/05/05
- Re: regexp with match over multiple lines, AngusC, 2011/05/05
- Re: regexp with match over multiple lines, Deniz Dogan, 2011/05/05
- Re: regexp with match over multiple lines, AngusC, 2011/05/05
- Re: regexp with match over multiple lines,
PJ Weisberg <=
- Re: regexp with match over multiple lines, Peter Dyballa, 2011/05/05
- Re: regexp with match over multiple lines, AngusC, 2011/05/06
- Re: regexp with match over multiple lines, Peter Dyballa, 2011/05/06
- Re: regexp with match over multiple lines, AngusC, 2011/05/06
- Re: regexp with match over multiple lines, Peter Dyballa, 2011/05/06
Re: regexp with match over multiple lines, ken, 2011/05/05
Re: regexp with match over multiple lines, Andreas Röhler, 2011/05/05