Jump to content

splitting string sentence.


Recommended Posts

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.

post-7256-124998197437_thumb.png

  • Like 1
Link to comment

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.

post-7256-124998197437_thumb.png

That is a nice code. I really Like it.

what would be the difference between them in the sense that which will be faster.

Link to comment

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.

post-7256-124998197437_thumb.png

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.

Link to comment

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 exp​ression 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 exp​ressions and look at the LabVIEW help for the "match regular exp​ression'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

post-7256-125006697474_thumb.png

cheers

Dannyt

  • Like 1
Link to comment

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

  • Like 1
Link to comment

Morning again.

Couple of things first. I strongly suggest you read a little about regular exp​ression 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 exp​ressions and look at the LabVIEW help for the "match regular exp​ression'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

post-7256-125006697474_thumb.png

cheers

Dannyt

Thanks alot guys. It helps alot & thanks for the regular expressions link.

Link to comment
  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.