Anyone fluent in regex?
- Anmelden oder Registrieren um Kommentare zu schreiben
It's related to an org file, so I can have in it:
*
**
***
****
and so on.
I'm trying to colorize all the stars (*) but the last one on the right.
Up until now I came up with this:
/(\*)\*/
Here's some help for what it does:
http://rick.measham.id.au/paste/explain.pl?regex=%5E%28%5C*%29%5C*
Basically, it only displays and colorize 1 star if there's one after (2 stars become one, and it's colorized).
Yet if there's more than 2, they are also displayed, but only one on the left is colorized (if there are 4, one on the left is colorized, followed by 2 others not colorized).
I want all the stars displayed, no matter how much there is, and color all the stars but the last one on the right.
I spent a few hours on this (tutorials and stuff), so I thought I might ask for some hints.
Try this: \**(?=\*)
Now nothing appears :/
but if I remove the lookahead part "?=", thing appear again, but the only one star appears, no matter howw much there is on the line.
I thinks it does "exclusively show and color only the last star on the right." This would actually be fine if it also showed the other uncolored stars before it.
Now this (\**\*)\* gives:
* remains * uncolored
** becomes * colored
*** becomes ** colored
and so on.
I thinks it's because between parenthesis, that's what remains, and that's what's colored. After the parenthesis is probably the condition.
It's what is displayed that's hard to keep. Maybe related, less and less of the org file is displayed the more I write regex rules.
I even tried (.)\* which gives the same result as (\*)\*
EDIT: One solution is to ""hard code" a * right after the bit of code that colors the former stars.
http://irc.netsplit.de/channels/?chat=regex
#regex freenode - IRC Channel
Woah nice, thanks Mangy Dog !
Have fun hack & hack ;-)
- Anmelden oder Registrieren um Kommentare zu schreiben