labviewnoob Posted August 11, 2009 Report Share Posted August 11, 2009 Hi, im trying to split a string sentence into many parts. for example,"How do i split string sentences". i wish to split them word by word. can anyone give me an idea on how i could go about splitting the sentence. Many Thanks. Quote Link to comment
dannyt Posted August 11, 2009 Report Share Posted August 11, 2009 Hi, It all depends on what you want to actually do with the split parts afterwards, there are several ways to skin this cat, typically you use the match pattern, match regular pattern , split string function in a while loop until you find no more matches. you can also do it all at once using the spreadsheet string to array. 1 Quote Link to comment
Mark Yedinak Posted August 11, 2009 Report Share Posted August 11, 2009 You can also use the "Scan String for Tokens" or the "Search/Split String" VIs under the Additional String functions palette. I would suggest that you look through the examples for working with strings. Quote Link to comment
Novice2006 Posted August 11, 2009 Report Share Posted August 11, 2009 Hi, It all depends on what you want to actually do with the split parts afterwards, there are several ways to skin this cat, typically you use the match pattern, match regular pattern , split string function in a while loop until you find no more matches. you can also do it all at once using the spreadsheet string to array. That is a nice code. I really Like it. what would be the difference between them in the sense that which will be faster. Quote Link to comment
labviewnoob Posted August 12, 2009 Author Report Share Posted August 12, 2009 Hi, It all depends on what you want to actually do with the split parts afterwards, there are several ways to skin this cat, typically you use the match pattern, match regular pattern , split string function in a while loop until you find no more matches. you can also do it all at once using the spreadsheet string to array. Hi. Thanks alot. that was what i needed. However, if my string comes in the following format (8/12/2009 10:13:36 AM 1A), the AM would be seperated from my time. The AM is crucial as i am required to insert it into my database together with the time. This is the reason why i would like to split the string. Also, can you tell me how i can retrieve each word from the array as i will need to update the values into my database. Many Thanks. Quote Link to comment
dannyt Posted August 12, 2009 Report Share Posted August 12, 2009 Hi. Thanks alot. that was what i needed. However, if my string comes in the following format (8/12/2009 10:13:36 AM 1A), the AM would be separated from my time. The AM is crucial as I am required to insert it into my database together with the time. This is the reason why i would like to split the string. Also, can you tell me how i can retrieve each word from the array as I will need to update the values into my database. Many Thanks. Morning again. Couple of things first. I strongly suggest you read a little about regular expression and how to use them, then have a play with them. They are very powerful for this type of thing involving a predictable pattern and splitting it up. Try Regular expressions and look at the LabVIEW help for the "match regular expression's". I would also suggest you would be better working with a 24 hour clock system rather than AM and PM, from past experience I think using AM and PM will lead you to nothing but woe; when you come to get data out of the database and analyse the results things can get messy. Also where are you getting your time from if you are using LabVIEW its self then you would be better using the LabVIEW timestamp type. Anyway some example below that might help you cheers Dannyt 1 Quote Link to comment
Bjarne Joergensen Posted August 12, 2009 Report Share Posted August 12, 2009 Hej Danyt If your example has to work you must change the Regular exspresion from this "..:..:..\s(AM)|(PM)" to this "..:..:..\s(AM)|..:..:..\s(PM)" . regards Bjarne 1 Quote Link to comment
dannyt Posted August 12, 2009 Report Share Posted August 12, 2009 Hej Danyt If your example has to work you must change the Regular exspresion from this "..:..:..\s(AM)|(PM)" to this "..:..:..\s(AM)|..:..:..\s(PM)" . regards Bjarne quite right well noticed :-) or you could use ..:..:..\s(A|P)M well I did say to "play around a bit" dannyt 1 Quote Link to comment
labviewnoob Posted August 13, 2009 Author Report Share Posted August 13, 2009 Morning again. Couple of things first. I strongly suggest you read a little about regular expression and how to use them, then have a play with them. They are very powerful for this type of thing involving a predictable pattern and splitting it up. Try Regular expressions and look at the LabVIEW help for the "match regular expression's". I would also suggest you would be better working with a 24 hour clock system rather than AM and PM, from past experience I think using AM and PM will lead you to nothing but woe; when you come to get data out of the database and analyse the results things can get messy. Also where are you getting your time from if you are using LabVIEW its self then you would be better using the LabVIEW timestamp type. Anyway some example below that might help you cheers Dannyt Thanks alot guys. It helps alot & thanks for the regular expressions link. Quote Link to comment
syrpimp Posted August 8, 2014 Report Share Posted August 8, 2014 exactly what i'm looking for Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.