I'm not a n00b when it comes to regex, but I haven't been able to figure this one out. This is for VIM syntax highlighting, and the regex that vim uses is basic and somewhat similar to perl. I have a string like the following: ::blah::111::something::what I wantAs you can probably guess, I want to match on whatever's in place of "what I want". "blah", "111", "something", and "what I want" will always be different, so I can't just match on the string itselfThis will match on the whole string and capture what I want in the 4th group, but I don't believe there's any way in vim for me to use this out side of search&replace:
\(::\w\+\)\(::\d\+\)\(::\w\+\)\(::.*\)
\(::.*?\)$
\(::.*$\)\{-}
2/11/2011 7:24:26 PM
2/14/2011 11:41:01 AM
http://xkcd.com/208/
2/14/2011 11:50:46 AM
here are some lazy ways to do it.whatuwant=s.substring(s.lastindexof("::")+2)s2[] = s.split("::")whatuwant=s2[s2.length-1];[Edited on February 14, 2011 at 12:22 PM. Reason : 1]
2/14/2011 11:56:16 AM
::[^:]+::[^:]+::[^:]+:[^\n]+)
2/15/2011 9:27:59 PM
::[^:]+::[^:]+::[^:]+::([^\n]+)
2/15/2011 9:32:19 PM
2/16/2011 5:43:36 PM
What do you mean it matches the whole string but not the section you want?
2/16/2011 6:02:21 PM
([^:]+)$ maybeassuming there are no colons in what u want[Edited on February 16, 2011 at 6:05 PM. Reason : if you rotate your head to the side it kinda looks like a happy pope]
2/16/2011 6:04:41 PM
oh. i'd rather kill myself than use vim.
2/16/2011 6:52:45 PM
^^ well shit, that works when there's no colons in there. unfortunately, many lines have one or more additional colons in the section I want now that I think about it. fail on my part there
2/16/2011 6:58:33 PM
^^
2/16/2011 8:36:18 PM
bitches, the both of you. vim is amazing
2/18/2011 10:14:08 AM
can you use look ahead in VIM?
2/18/2011 1:33:47 PM
define "look ahead"
2/18/2011 3:55:10 PM
http://www.regular-expressions.info/lookaround.htmlI can't think of how to apply this at the moment, but I bet it is probably what you need. Though if VIM doesn't support the non-greedy, then it probably won't support lookaround either.
2/18/2011 9:55:11 PM
2/21/2011 2:58:23 AM
2/21/2011 8:47:59 PM
^^^That site is basically the online version of the Help file for the best-regarded regex program in the business: http://www.regexbuddy.com/index.htmlby an outfit called Just Great Software; too bad it's not free, but some free alternatives are given here: https://secure.wikimedia.org/wikipedia/en/wiki/RegexBuddy
2/24/2011 10:08:09 PM
i'd rather kill myself than anything other than vim.
2/25/2011 8:55:37 AM