[TxMt] OT: Perl Compatible Regex problem I can't solve

Erich Ocean subscriber at ampede.com
Thu Apr 7 18:23:15 UTC 2005


Why are you using a regex for this? Why not simply split the string 
using '/' as the delemiter, and get the results back in an array? Then 
you can used indexed access and get the "captures" that way. Or perhaps 
I'm missing something here...

Best, Erich

On Apr 7, 2005, at 10:26 AM, Mats Persson wrote:

>
> OK, for way too many hours I have been trying to get this seemingly 
> simple Perl compatible regex to work out, but I just can't seem to do 
> it. I'm about to give up, move to a dark cave and shun computers for 
> life. :(
>
> The problem:
>
> I have a string that is looking something like this:   /a/b/c/d/
> the string can be just    /a/    or it can be      /a/b/..../z/       
> very long.
>
> I would like to catch all the various bits in this string [   
> /a/b/c/d/   ]  as follows:
> $1 =  /a/
> $2 = b/
> $3 = c/
> $4 = d/
>
> and so on for each added bit. The bits in between the "/" contains 
> mainly [alphnums].
>
> I've tried every regex version of this that I can think of and most 
> don't return a damn thing, and others return the wrong things.  A few 
> days ago I thought I got this regex stuff, but now I'm in serious 
> doubt.
>
> I know that I can workaround the problem by doing other things, but 
> it's become a bit of a burden on my mind. I'd like to know where I'm 
> going wrong 'cause I can't see it at the moment and that drives me 
> mad.
>
> Extremely over the top grateful for any help. :)
>
>
> Kind regards,
>
> Mats
>
> ----
> "TextMate, coding with an incredible sense of joy and ease"
> - www.macromates.com -
>
> ______________________________________________________________________
> 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
>




More information about the textmate mailing list