[TxMt] a newbie asks for help with regular expressions
singletoned at gmail.com
Fri Aug 18 08:22:48 UTC 2006
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.
Which looks even prettier (though the ^ does spoil it a little)
More information about the textmate