Regexp frustration!

4nt0n's icon

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!

pdelges's icon

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

4nt0n's icon

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...

pdelges's icon

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

regexp \| @substitute " "

andrea agostini's icon

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

4nt0n's icon

@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

pdelges's icon

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

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

p

4nt0n's icon

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

Luke Hall's icon

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.