Variant Posted November 4, 2008 Report Share Posted November 4, 2008 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. Quote Link to comment
Tomi Maila Posted November 4, 2008 Report Share Posted November 4, 2008 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 Quote Link to comment
Variant Posted November 4, 2008 Author Report Share Posted November 4, 2008 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 ? Quote Link to comment
Minh Pham Posted November 5, 2008 Report Share Posted November 5, 2008 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 Quote Link to comment
Variant Posted November 5, 2008 Author Report Share Posted November 5, 2008 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 thanks for the Example Quote Link to comment
jdunham Posted November 5, 2008 Report Share Posted November 5, 2008 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). Quote Link to comment
Variant Posted November 5, 2008 Author Report Share Posted November 5, 2008 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. Quote Link to comment
jdunham Posted November 5, 2008 Report Share Posted November 5, 2008 QUOTE (Variant @ Nov 4 2008, 02:00 PM) 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. Well like most things, you take a class, read a book, search the internet, and/or ask your colleagues. Oh, and practice! (Bonus points to you for already having started with some of those methods). http://www.regular-expressions.info/ is a popular site, but there are many others. 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.