Jump to content

String Parsing


Variant

Recommended Posts

I need to know the best way to do this.

Let us say I have a template called Apple.vit . Everytime I open It it Open with a Count appended to it Like Apple 1.vi, Apple 2.vi......I am programmatically trying to save these instances of template different name. I need to remove the decimal number from the template instance..i.e I need to remove the "1" from apple 1.vi and "2" from apple 2.vi. Can anyone tell me which is the best method of doing it. Somtimes it might not be a template it can be a sub.vi which does not have this number. Scan from string throws an error for this reason....I am now doing it in round about way. I just wanted to check the Best way of doing it.

Link to comment

QUOTE (Tomi Maila @ Nov 3 2008, 10:34 PM)

I would do it with Match Regular Expression that you can find in the String menu. Make a regular expression that matches only the number there that you need to remove and then form the new file name from the before match and after match strings.

Tomi

Can you please give me an Example of Regular expression that find out the Number For this "This is Red apple 345673.vi" ...I guess the out put will be 345673 right ?

Link to comment

QUOTE (Variant @ Nov 4 2008, 10:37 AM)

Can you please give me an Example of Regular expression that find out the Number For this "This is Red apple 345673.vi" ...I guess the out put will be 345673 right ?

You have two ways to achieve this: Scan From String or Match Pattern, just look at the 'detail help' for these 2 functions, they are so powerful !!

Here is an example on how you can do this in both methods:

Have fun playing with String data type :yes:

Link to comment

QUOTE (Minh Pham @ Nov 4 2008, 03:19 AM)

You have two ways to achieve this: Scan From String or Match Pattern, just look at the 'detail help' for these 2 functions, they are so powerful !!

Here is an example on how you can do this in both methods:

Have fun playing with String data type :yes:

thanks for the Example

Link to comment

QUOTE (Minh Pham @ Nov 3 2008, 07:19 PM)

You have two ways to achieve this: Scan From String or Match Pattern, just look at the 'detail help' for these 2 functions, they are so powerful !!

I don't think it's safe to assume that the base file name doesn't have any numbers in it, so I think you need a more sophisticated regexp than [0-9]+

If you use

\s[0-9]+(?=\.vi$)

then it will find the number right before the extension, including the leading space. This only works with the Match Regular Expression function, not the older and simpler Match Pattern function.

However, I gotta ask what you are trying to do? Cloning VIs is way easier than making your own copies of templates. Thats how we spawn off multiple processes and multiple instances of a pop-up GUI. You can search LAVA for more details (that's how I learned about them).

Link to comment

QUOTE (jdunham @ Nov 4 2008, 08:21 AM)

I don't think it's safe to assume that the base file name doesn't have any numbers in it, so I think you need a more sophisticated regexp than [0-9]+

If you use

\s[0-9]+(?=\.vi$)

then it will find the number right before the extension, including the leading space. This only works with the Match Regular Expression function, not the older and simpler Match Pattern function.

However, I gotta ask what you are trying to do? Cloning VIs is way easier than making your own copies of templates. Thats how we spawn off multiple processes and multiple instances of a pop-up GUI. You can search LAVA for more details (that's how I learned about them).

No this is different. This is to reduce the job of repeated work. How do you guys know these regular expression. How do we construct this regular expression is there any way of doing it or approaching it. Please help i need to learn that.

Link to comment

Join the conversation

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

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