* regexp on emacs how to...
@ 2014-08-30 21:01 renato.pontefice
2014-08-30 22:17 ` Thorsten Jolitz
2014-09-01 9:56 ` Nicolas Richard
0 siblings, 2 replies; 23+ messages in thread
From: renato.pontefice @ 2014-08-30 21:01 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I need a regexp, that can help me, on a particular need.
I have a file in .rtf format.
Inside it, with emacs, i insert some code.
All the code that I insert, start with [- and ends with -]
betwwen this two tags I have capital letters, without space and line breack.
I would have a regexp that show me any occurence of this tag, where i.e.:
- there are open tag [-
- name of variable [-VARIABLENAME
but the close tag -] are after a line break
and i.e.
- start tag [-
- some char of variable (written in capital letters) [-VARIABLE
- but before the end tag, some non capital letter (that is .rtf code) [-VARIABLE\rtf\ql\lind34}NAME-]
I hope I have well explained. (if not, ask me more clarifications)
is it possible?
thank you
Renato
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-08-30 21:01 regexp on emacs how to renato.pontefice
@ 2014-08-30 22:17 ` Thorsten Jolitz
2014-08-30 22:39 ` Thorsten Jolitz
[not found] ` <mailman.7955.1409438369.1147.help-gnu-emacs@gnu.org>
2014-09-01 9:56 ` Nicolas Richard
1 sibling, 2 replies; 23+ messages in thread
From: Thorsten Jolitz @ 2014-08-30 22:17 UTC (permalink / raw)
To: help-gnu-emacs
renato.pontefice@gmail.com writes:
> Hi,
> I need a regexp, that can help me, on a particular need.
>
> I have a file in .rtf format.
> Inside it, with emacs, i insert some code.
>
> All the code that I insert, start with [- and ends with -]
>
> betwwen this two tags I have capital letters, without space and line
> breack.
>
> I would have a regexp that show me any occurence of this tag, where i.e.:
> - there are open tag [-
> - name of variable [-VARIABLENAME
> but the close tag -] are after a line break
>
> and i.e.
> - start tag [-
> - some char of variable (written in capital letters) [-VARIABLE
> - but before the end tag, some non capital letter (that is .rtf code)
> [-VARIABLE\rtf\ql\lind34}NAME-]
>
> I hope I have well explained. (if not, ask me more clarifications)
>
> is it possible?
This might give some false positives, but not miss any tags:
"\\[-[^^\000]+?-]"
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-08-30 22:17 ` Thorsten Jolitz
@ 2014-08-30 22:39 ` Thorsten Jolitz
[not found] ` <mailman.7955.1409438369.1147.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 23+ messages in thread
From: Thorsten Jolitz @ 2014-08-30 22:39 UTC (permalink / raw)
To: help-gnu-emacs
Thorsten Jolitz <tjolitz@gmail.com> writes:
> This might give some false positives, but not miss any tags:
>
> "\\[-[^^\000]+?-]"
Ups, this should actually be:
"\\[-[^\000]+?-]"
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 23+ messages in thread
[parent not found: <mailman.7955.1409438369.1147.help-gnu-emacs@gnu.org>]
* Re: regexp on emacs how to...
[not found] ` <mailman.7955.1409438369.1147.help-gnu-emacs@gnu.org>
@ 2014-09-01 8:15 ` renato.pontefice
2014-09-01 8:24 ` Eric Abrahamsen
` (2 more replies)
0 siblings, 3 replies; 23+ messages in thread
From: renato.pontefice @ 2014-09-01 8:15 UTC (permalink / raw)
To: help-gnu-emacs
Il giorno domenica 31 agosto 2014 00:39:00 UTC+2, Thorsten Jolitz ha scritto:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>
>
> > This might give some false positives, but not miss any tags:
>
> >
>
> > "\\[-[^^\000]+?-]"
>
>
>
> Ups, this should actually be:
>
>
>
> "\\[-[^\000]+?-]"
>
>
>
> --
>
> cheers,
>
> Thorsten
It doesen't work :-(
can you try to explain me what kin of search try to do this expression?
TIA
Renato
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-09-01 8:15 ` renato.pontefice
@ 2014-09-01 8:24 ` Eric Abrahamsen
2014-09-01 9:14 ` Thorsten Jolitz
2014-09-01 9:10 ` Thorsten Jolitz
[not found] ` <mailman.8023.1409562921.1147.help-gnu-emacs@gnu.org>
2 siblings, 1 reply; 23+ messages in thread
From: Eric Abrahamsen @ 2014-09-01 8:24 UTC (permalink / raw)
To: help-gnu-emacs
renato.pontefice@gmail.com writes:
> Il giorno domenica 31 agosto 2014 00:39:00 UTC+2, Thorsten Jolitz ha scritto:
>> Thorsten Jolitz <tjolitz@gmail.com> writes:
>>
>>
>>
>> > This might give some false positives, but not miss any tags:
>>
>> >
>>
>> > "\\[-[^^\000]+?-]"
>>
>>
>>
>> Ups, this should actually be:
>>
>>
>>
>> "\\[-[^\000]+?-]"
>>
>>
>>
>> --
>>
>> cheers,
>>
>> Thorsten
>
> It doesen't work :-(
>
> can you try to explain me what kin of search try to do this expression?
In cases like this, regexp-builder can often be useful. Go to the buffer
containing your RTF text, M-x regexp-builder, and then start building
your regexp incrementally. Many times this is enough to show you what
was wrong with the original one.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-09-01 8:24 ` Eric Abrahamsen
@ 2014-09-01 9:14 ` Thorsten Jolitz
0 siblings, 0 replies; 23+ messages in thread
From: Thorsten Jolitz @ 2014-09-01 9:14 UTC (permalink / raw)
To: help-gnu-emacs
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> In cases like this, regexp-builder can often be useful. Go to the buffer
> containing your RTF text, M-x regexp-builder, and then start building
> your regexp incrementally. Many times this is enough to show you what
> was wrong with the original one.
Indeed, a very useful library.
Only caveat in this case: when using [^\000]+ in a regexp and calling
'reb-copy', it is converted to a literal NUL char [^^@]+, which works
perfectly for regexp matching, but makes GIT think your .el file is a
binary file.
I had this problem and had to change all [^^@]+ back to [^\000]+ to
enable correct VC on these files again ... (including some renaming
workarounds).
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-09-01 8:15 ` renato.pontefice
2014-09-01 8:24 ` Eric Abrahamsen
@ 2014-09-01 9:10 ` Thorsten Jolitz
[not found] ` <mailman.8023.1409562921.1147.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 23+ messages in thread
From: Thorsten Jolitz @ 2014-09-01 9:10 UTC (permalink / raw)
To: help-gnu-emacs
renato.pontefice@gmail.com writes:
> Il giorno domenica 31 agosto 2014 00:39:00 UTC+2, Thorsten Jolitz ha
> scritto:
>> Thorsten Jolitz <tjolitz@gmail.com> writes:
>> "\\[-[^\000]+?-]"
> It doesen't work :-(
>
> can you try to explain me what kin of search try to do this expression?
Can you just give a simple example of what text you would like to match?
E.g. insert a typical snippet in a lorem ipsum paragraph or so:
#+BEGIN_EXAMPLE
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam nisl,
tincidunt et, mattis eget, [MY SNIPPET] convallis nec, purus. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Nulla posuere. Donec vitae dolor. Nullam tristique diam non
turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam vestibulum
accumsan nisl.
#+END_EXAMPLE
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 23+ messages in thread
[parent not found: <mailman.8023.1409562921.1147.help-gnu-emacs@gnu.org>]
* Re: regexp on emacs how to...
[not found] ` <mailman.8023.1409562921.1147.help-gnu-emacs@gnu.org>
@ 2014-09-01 10:11 ` renato.pontefice
2014-09-01 10:28 ` Thorsten Jolitz
2014-09-01 10:38 ` Álvar Ibeas
0 siblings, 2 replies; 23+ messages in thread
From: renato.pontefice @ 2014-09-01 10:11 UTC (permalink / raw)
To: help-gnu-emacs
ok, this is a right code:
#+BEGIN_EXAMPLE
noscenza e competenza, che in }{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996\charrsid7868964 [-DATE-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 prot }{\rtlch\fcs1 \af0 \ltrch\fcs0
\f40\fs22\insrsid15731996\charrsid13987552 [-TIME-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 Il/la sig
#+END_EXAMPLE
this is an example with problems
#+BEGIN_EXAMPLE
noscenza e competenza, che in }{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996\charrsid7868964 [-DAT{\rtlch\fcs1 \af0 \ltrchE-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 prot }{\rtlch\fcs1 \af0 \ltrch\fcs0
\f40\fs22\insrsid15731996\charrsid13987552 [-TI
ME-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 Il/la sig
#+END_EXAMPLE
In the second example, my variable ([-DATE-] and [-TIME-], are interrupted:
- in [-DATE-] variable, by rtf code
- in [-TIME-] variable, by a a line feed
in both example, the parser that try to substituite variable, fails, becausae it find some dirty text, between the start [- and the end -] of variable.
So I need to detect that occurence.
The best thing would be to detect JUST the occurence of variable that are not well formatted (as in example 1
I think regexp could do that, but I don't know how...
Renato
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-09-01 10:11 ` renato.pontefice
@ 2014-09-01 10:28 ` Thorsten Jolitz
2014-09-01 10:38 ` Álvar Ibeas
1 sibling, 0 replies; 23+ messages in thread
From: Thorsten Jolitz @ 2014-09-01 10:28 UTC (permalink / raw)
To: help-gnu-emacs
renato.pontefice@gmail.com writes:
> ok, this is a right code:
> #+BEGIN_EXAMPLE
> noscenza e competenza, che in }{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996\charrsid7868964 [-DATE-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 prot }{\rtlch\fcs1 \af0 \ltrch\fcs0
> \f40\fs22\insrsid15731996\charrsid13987552 [-TIME-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 Il/la sig
> #+END_EXAMPLE
>
> this is an example with problems
> #+BEGIN_EXAMPLE
> noscenza e competenza, che in }{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996\charrsid7868964 [-DAT{\rtlch\fcs1 \af0 \ltrchE-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 prot }{\rtlch\fcs1 \af0 \ltrch\fcs0
> \f40\fs22\insrsid15731996\charrsid13987552 [-TI
> ME-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 Il/la sig
> #+END_EXAMPLE
>
> In the second example, my variable ([-DATE-] and [-TIME-], are interrupted:
> - in [-DATE-] variable, by rtf code
> - in [-TIME-] variable, by a a line feed
>
> in both example, the parser that try to substituite variable, fails,
> becausae it find some dirty text, between the start [- and the end -]
> of variable.
>
> So I need to detect that occurence.
> The best thing would be to detect JUST the occurence of variable that
> are not well formatted (as in example 1
>
> I think regexp could do that, but I don't know how...
Hmm ... when I start M-x regexp-builder and insert "\\[-[^\000]+?-]",
and then call M-x reb-force-update, all the variables in you post above
are matched. So this seems to work, but try there more profound advice
from Nicolas too.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-09-01 10:11 ` renato.pontefice
2014-09-01 10:28 ` Thorsten Jolitz
@ 2014-09-01 10:38 ` Álvar Ibeas
1 sibling, 0 replies; 23+ messages in thread
From: Álvar Ibeas @ 2014-09-01 10:38 UTC (permalink / raw)
To: help-gnu-emacs
MIME-Version: 1.0
Content-Type: text/plain
\[-[A-Z]*?[^]A-Z]+?[^]]*?-\]
It misses at least those occurrences where the character ] is in the inserted text.
Date: Mon, 01 Sep 2014 12:38:30 +0200
In-Reply-To: <0f557f31-c018-4844-b852-d8be48dda000@googlegroups.com> (renato
pontefice's message of "Mon, 1 Sep 2014 03:11:17 -0700")
Message-ID: <87egvvr5g9.fsf@alveinte.minas.unican.es>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
--text follows this line--
<renato.pontefice@gmail.com> writes:
> ok, this is a right code:
> #+BEGIN_EXAMPLE
> noscenza e competenza, che in }{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996\charrsid7868964 [-DATE-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 prot }{\rtlch\fcs1 \af0 \ltrch\fcs0
> \f40\fs22\insrsid15731996\charrsid13987552 [-TIME-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 Il/la sig
> #+END_EXAMPLE
>
> this is an example with problems
> #+BEGIN_EXAMPLE
> noscenza e competenza, che in }{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996\charrsid7868964 [-DAT{\rtlch\fcs1 \af0 \ltrchE-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 prot }{\rtlch\fcs1 \af0 \ltrch\fcs0
> \f40\fs22\insrsid15731996\charrsid13987552 [-TI
> ME-]}{\rtlch\fcs1 \af0 \ltrch\fcs0 \f40\fs22\insrsid15731996 Il/la sig
> #+END_EXAMPLE
>
> In the second example, my variable ([-DATE-] and [-TIME-], are interrupted:
> - in [-DATE-] variable, by rtf code
> - in [-TIME-] variable, by a a line feed
>
> in both example, the parser that try to substituite variable, fails, becausae it find some dirty text, between the start [- and the end -] of variable.
>
> So I need to detect that occurence.
> The best thing would be to detect JUST the occurence of variable that are not well formatted (as in example 1
>
> I think regexp could do that, but I don't know how...
>
> Renato
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: regexp on emacs how to...
2014-08-30 21:01 regexp on emacs how to renato.pontefice
2014-08-30 22:17 ` Thorsten Jolitz
@ 2014-09-01 9:56 ` Nicolas Richard
[not found] ` <CAF83ECB74PD7An-scqk74gN4YzrGC9DW8at1-cCFzV1utYSFRQ@mail.gmail.com>
1 sibling, 1 reply; 23+ messages in thread
From: Nicolas Richard @ 2014-09-01 9:56 UTC (permalink / raw)
To: renato.pontefice; +Cc: help-gnu-emacs
renato.pontefice@gmail.com writes:
> I would have a regexp that show me any occurence of this tag, where i.e.:
> - there are open tag [-
> - name of variable [-VARIABLENAME
> but the close tag -] are after a line break
Do you really need to do it with a regexp ? Here's some lisp to search
for all these problematic tags.
(while (and (not (eobp)) (search-forward "[-" nil t))
(unless (search-forward "-]" (point-at-eol) 'move)
(message "Problem found, please fix and hit C-M-c to continue")
(recursive-edit)))
If you really want a regexp, you could use
(re-search-forward "\\[-\\([^-]\\|-[^]]\\)*\n")
(i.e. match a "[-" not followed by "-]" on the same line)
At the C-M-% prompt, you can enter the regexp as \[-\([^-]\|-[^]]\)* followed by a
litteral newline, i.e. C-q C-j.
HTH,
--
Nicolas Richard
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2014-09-11 7:29 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-30 21:01 regexp on emacs how to renato.pontefice
2014-08-30 22:17 ` Thorsten Jolitz
2014-08-30 22:39 ` Thorsten Jolitz
[not found] ` <mailman.7955.1409438369.1147.help-gnu-emacs@gnu.org>
2014-09-01 8:15 ` renato.pontefice
2014-09-01 8:24 ` Eric Abrahamsen
2014-09-01 9:14 ` Thorsten Jolitz
2014-09-01 9:10 ` Thorsten Jolitz
[not found] ` <mailman.8023.1409562921.1147.help-gnu-emacs@gnu.org>
2014-09-01 10:11 ` renato.pontefice
2014-09-01 10:28 ` Thorsten Jolitz
2014-09-01 10:38 ` Álvar Ibeas
2014-09-01 9:56 ` Nicolas Richard
[not found] ` <CAF83ECB74PD7An-scqk74gN4YzrGC9DW8at1-cCFzV1utYSFRQ@mail.gmail.com>
2014-09-02 10:53 ` Nicolas Richard
[not found] ` <874mwrrudt.fsf@yahoo.fr>
[not found] ` <CAF83ECB2NbV0QdCbd0H8Z-PJB0ZbYboswpjFudc__9JQH+P=1Q@mail.gmail.com>
2014-09-02 11:03 ` Nicolas Richard
[not found] ` <mailman.8096.1409655669.1147.help-gnu-emacs@gnu.org>
2014-09-03 9:24 ` renato.pontefice
2014-09-03 9:25 ` renato.pontefice
2014-09-03 10:47 ` Nicolas Richard
[not found] ` <mailman.8184.1409741111.1147.help-gnu-emacs@gnu.org>
2014-09-04 10:48 ` Renato Pontefice
2014-09-05 12:02 ` Nicolas Richard
[not found] ` <mailman.8325.1409918483.1147.help-gnu-emacs@gnu.org>
2014-09-10 8:55 ` Renato Pontefice
2014-09-10 10:01 ` Nicolas Richard
[not found] ` <mailman.8606.1410343132.1147.help-gnu-emacs@gnu.org>
2014-09-10 10:20 ` Renato Pontefice
2014-09-10 13:52 ` Nicolas Richard
[not found] ` <mailman.8618.1410357057.1147.help-gnu-emacs@gnu.org>
2014-09-11 7:29 ` Renato Pontefice
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).