[TxMt] a newbie asks for help with regular expressions

Lawrence Goodman lawrencegoodman at gmail.com
Fri Aug 18 17:24:50 UTC 2006


Thanks for the help. If you'll indulge me one more tiime:

So now I have written:
{	name = 'element.comment.first';
			match = '[*][^*]*[*]';
		},

If the line reads *;lk;lk* it captures what's between the asterisks.
If the line reads *lkjsdflkjs* hello there *sjlfskjd*, it will capture
both elements between the asterisks.
BUT if the line is:
Hello there *lskjdflsjdfsl* I want to go, it doesn't capture what is
between the asterisks.

Any more suggestions?

Thanks.



On 8/18/06, Ed Singleton <singletoned at gmail.com> wrote:
> On 8/18/06, Allan Odgaard <throw-away-1 at macromates.com> wrote:
> > On 17/8/2006, at 22:04, Lawrence Goodman wrote:
> >
> > > [...] For example if I type:
> > > * Textmate *
> > > This would be identified as element.comment.first.
> > >
> > > So I wrote the following [...]
> > >
> > >     match = '[*]\s?([^\* ]|\.| [*] | )*[*]';
> >
> > That is a somewhat puzzling pattern. It matches *, optional
> > whitespace, a sequence of 'not * or space' or the '.' character, or
> > the ' * ' sequence. And then finally a '*'.
> >
> > The second branch is redundant and the third I think is unwanted.
> >
> > > The problem is it can't identify the element when it comes in the
> > > middle or end of a line, i.e.
> > > I want to learn how to use * Textmate * tomorrow.
> >
> > What it can't identify is when the terminating '*' has spaces on both
> > sides, as it will then be taken by your middle repeat, and the
> > terminating state is never met.
> >
> > > Any suggestions or help would be much appreciated. Thanks.
> >
> > Well, not entirely sure what you want to match, but sounds like just:
> >
> >     [*].*?[*]
> >
> > That matches from asterisk to asterisk.
>
> Or
>
> [*][^*]*[*]
>
> Which looks even prettier (though the ^ does spoil it a little)
>
> Ed
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>


-- 
Lawrence Goodman
lawrencegoodman at gmail.com
Check out my blog: http://goodmanorama.blogspot.com



More information about the textmate mailing list