Regexp frustration!

Dec 13, 2010 at 2:40pm

Regexp frustration!

I am trying to break down this message:
media/Blackbird.m4v|Blackbird|Standard|anton|

by using regexp but I am unable. In fact it drives me crazy!
all I want is to separate each substring in the place where the | exists!
any ideas plz!

#53861
Dec 13, 2010 at 2:53pm

If you don’t have spaces in your message (but something in your message looks like a filepath…), then fromsymbol @separator | may be enough for your needs.

p

#193894
Dec 13, 2010 at 2:58pm

thank you Patrick,
you are right the first part it is a file path and it may contain spaces. :-/
so I need a more general approach…

#193895
Dec 13, 2010 at 3:00pm

But if you really want to use regular expressions, try something like this:

regexp \| @substitute ” “

#193896
Dec 13, 2010 at 3:07pm

You can use [fromsymbol @separator |] even if your message contains spaces, provided it’s a single symbol (which should be in any case, otherwise you’d lose every sequence of multiple spaces that might appear in the file path).

aa

#193897
Dec 13, 2010 at 3:14pm

@Andrea true it seems that [fromsymbol @separator |] is working with spaces. What do u mean single symbol?
@Patrick that way [regexp \| @substitute " "] I can seperate them but I will loose track of the individual pieces if they contain spaces

#193898
Dec 13, 2010 at 3:15pm

Sorry, I didn’t see you needed spaces before sending the regular expression.

This should work, using the 2nd outlet: regexp (.+)\|(.+)\|(.+)\|(.+)\|

p

#193899
Dec 13, 2010 at 3:18pm

Super!
That what I was trying to come up with but instaed of . I was using w :-)
thank you both of you!

#193900
Dec 14, 2010 at 3:06am

Pretty much the same as Patrick’s method but a little more efficient:

regexp ([^|]+)\|([^|]+)\|([^|]+)\|([^|]+)

This expression captures anything-that-isn’t-a-vertical-bar between other vertical bar, it’s a little bit speedier than the anything-at-all method.

#193901

You must be logged in to reply to this topic.