Login | Register 
Products Applications Downloads Features Wiki forum Store
 

regex delimiters

Still a little green? Ask your beginner's questions here

regex delimiters

Postby rhaines » Sun Jun 14, 2009 12:55 pm

In a DAT string, how do I convert a space to a tab?

Code: Select all
     substitute($V," ",\t)

seems right, but it appends a literal "\t" in every blankspace when I do it. Put it in quotes and the same thing happens.

...And how should I have found the answer without asking online?

Many thanks.
rhaines
 
Posts: 35
Joined: Mon Nov 17, 2008 8:51 am

Re: regex delimiters

Postby ben » Mon Jun 15, 2009 2:12 pm

There are a few ways to do this:

Code: Select all
substitute($V, " ", "     ")
where you press the <tab> key in between the second set of quotes.

Or you can use the ftoc() expression, which turns a float into a character
Code: Select all
substitute("$V", " ", ftoc(9))


Or you can use 2 Convert DATs, the first converting To Table using " " for the Split Cells at parameter and the second converting To Text using \t for the Concatenate With parameter.
User avatar
ben
Staff
 
Posts: 865
Joined: Thu Nov 08, 2007 5:55 pm
Location: Toronto

Re: regex delimiters

Postby rhaines » Mon Jun 15, 2009 2:52 pm

Or you can use 2 Convert DATs, the first converting To Table using " " for the Split Cells at parameter[...]


Since I'm aiming for creating cells in a table, this would seem to be the simplest answer. It isn't working, however.

Here's a typical single line of data seen by the oscin DAT:
    4.94066e-324 /tuio/2Dcur "source" "OSCemote@e261e643fbceab57134e367d9d09203a815ff9dc" /tuio/2Dcur "set" 1 0.665625 0.557178 0 0 0 /tuio/2Dcur "set" 2 0.28125 0.635036 0 0 0 /tuio/2Dcur "alive" 1 2 /tuio/2Dcur "fseq" 586
With a convert DAT set to "To Table" and Split Cells At " ", the output is indistinguishable from the input. Why is that?
rhaines
 
Posts: 35
Joined: Mon Nov 17, 2008 8:51 am

Re: regex delimiters

Postby rhaines » Mon Jun 15, 2009 5:35 pm

(Answering my own question here:)

There is no change from input to output because the OSCin DAT is *already* a table, and the convert DAT apparently doesn't touch data within a table when "To Table" is selected. It seems like this behavior could safely and usefully be changed since the goal is to make table data even more table-y ("table-acious"? "tabuloid"? "tablish"?)

The workaround is to convert(DAT) "To Text", then convert(DAT) "To Table" with Split Cells At [space]. Note that using " ", including the quotes causes extra blank cells to be generated. Just a single space is needed in the field, which will look empty.
rhaines
 
Posts: 35
Joined: Mon Nov 17, 2008 8:51 am

Re: regex delimiters

Postby rob » Fri Mar 19, 2010 2:38 pm

rhaines wrote:(Answering my own question here:)

There is no change from input to output because the OSCin DAT is *already* a table, and the convert DAT apparently doesn't touch data within a table when "To Table" is selected. It seems like this behavior could safely and usefully be changed since the goal is to make table data even more table-y ("table-acious"? "tabuloid"? "tablish"?)

The workaround is to convert(DAT) "To Text", then convert(DAT) "To Table" with Split Cells At [space]. Note that using " ", including the quotes causes extra blank cells to be generated. Just a single space is needed in the field, which will look empty.


Just a heads up, convert DAT now converts from table to table in one shot.
Cheers.
User avatar
rob
Staff
 
Posts: 362
Joined: Tue Nov 13, 2007 12:14 am

Re: regex delimiters

Postby greg » Wed Aug 18, 2010 11:55 pm

Another heads up, now the Substitute DAT does string substitution, usually a bit easier than using the substitute() expression.
User avatar
greg
Staff
 
Posts: 291
Joined: Tue Nov 13, 2007 12:08 am

Re: regex delimiters

Postby ben » Tue Aug 31, 2010 3:57 pm

hey rhaines,

This thread is a bit old now, so you might already have your own implementation, but here is a little component that parses out 2Dcur messages from TUIO data sent into TouchDesigner. Maybe you or others will find it useful.

cheers!
tuio.tox
TouchDesigner 077 Build 7760
(3.94 KiB) Downloaded 79 times
User avatar
ben
Staff
 
Posts: 865
Joined: Thu Nov 08, 2007 5:55 pm
Location: Toronto


Return to Beginners

Who is online

Users browsing this forum: No registered users and 2 guests