guli34 Posted December 6, 2009 Report Share Posted December 6, 2009 I need to extract some ID # and sub ID from an URL string ex: http://yourid.xyz.com/index.cfm?fuseaction...esubID=18974678 (Click on the URL to see it in full) So I want to get 4317378244 and 18974678 in two separate variables knowing the length of text may vary with the #number of digits from the integer ID and the alphabetical part stay the same I am not sure how to achieve this . Quote Link to comment Share on other sites More sharing options...
rberq Posted December 6, 2009 Report Share Posted December 6, 2009 I need to extract some ID # and sub ID from an URL string ex: http://yourid.xyz.com/index.cfm?fuseaction...esubID=18974678 (Click on the URL to see it in full) So I want to get 4317378244 and 18974678 in two separate variables knowing the length of text may vary with the #number of digits from the integer ID and the alphabetical part stay the same I am not sure how to achieve this . Put the entire URL in T1 variable Variable Set Integer N1 to location of "ID=" in T1 Variable Modify Integer N1=N1+3 (to allow for the ID=) Variable Modify String T1 -- delete characters 1 through N1 At this point the first integer is at the beginning of string T1 because you deleted everything before it You know the number of digits in the integer (10), so Variable Modify String T1 -- copy 10 characters into T2 At this point you have isolated the first integer string into T2 Repeat above coding to isolate the second integer string into T3 Quote Link to comment Share on other sites More sharing options...
guli34 Posted December 6, 2009 Author Report Share Posted December 6, 2009 Put the entire URL in T1 variableVariable Set Integer N1 to location of "ID=" in T1 Variable Modify Integer N1=N1+3 (to allow for the ID=) Variable Modify String T1 -- delete characters 1 through N1 At this point the first integer is at the beginning of string T1 because you deleted everything before it You know the number of digits in the integer (10), so Variable Modify String T1 -- copy 10 characters into T2 At this point you have isolated the first integer string into T2 Repeat above coding to isolate the second integer string into T3 I followed your explanation, but what about if I do not know the number of digits in the first integer , in the example it is 10 but it can be between 4 and 13 same for the second integer of witch it should be easier to get since no character come after the digits. Quote Link to comment Share on other sites More sharing options...
rberq Posted December 6, 2009 Report Share Posted December 6, 2009 I followed your explanation, but what about if I do not know the number of digits in the first integer , in the example it is 10 but it can be between 4 and 13 same for the second integer of witch it should be easier to get since no character come after the digits. Sorry, I thought you said the number of digits would always be the same. Once the string of digits is at the beginning of the T1 variable, Variable Modify String T1 copy about 50 characters to T2 -- copy more than the largest number of digits you expect. Then write a repeat loop to step through the T2 characters one at a time checking whether they are numeric or not. Keep a count of how many characters are checked, in another Nx variable. When you finally get to a non-numeric, delete that and all subsequent characters from T2. What you are left with in T2 is just the numeric digits. Repeat the above to isolate the second string of digits into T3. It's a good idea, before starting this second process, to append a space to the T1 variable, so that you will be sure of finding a non-numeric (the space) before you come to the end of the T1 variable (in case the digits are the last thing in the URL). There are other ways of extracting the digits, one at a time, into T2 and T3; but the above should work. There may be a simpler method than stepping through the digits one at a time, but I don't know what it is. Quote Link to comment Share on other sites More sharing options...
guli34 Posted December 7, 2009 Author Report Share Posted December 7, 2009 Sorry, I thought you said the number of digits would always be the same. Once the string of digits is at the beginning of the T1 variable, Variable Modify String T1 copy about 50 characters to T2 -- copy more than the largest number of digits you expect. Then write a repeat loop to step through the T2 characters one at a time checking whether they are numeric or not. Keep a count of how many characters are checked, in another Nx variable. When you finally get to a non-numeric, delete that and all subsequent characters from T2. What you are left with in T2 is just the numeric digits. Repeat the above to isolate the second string of digits into T3. It's a good idea, before starting this second process, to append a space to the T1 variable, so that you will be sure of finding a non-numeric (the space) before you come to the end of the T1 variable (in case the digits are the last thing in the URL). There are other ways of extracting the digits, one at a time, into T2 and T3; but the above should work. There may be a simpler method than stepping through the digits one at a time, but I don't know what it is. Thank you , I will try your solution I found an other way but not as elegant! It is to convert T2 into integer witch keep only the digits, but this work for only 10 digits or 2,147,483,647 Max. Quote Link to comment Share on other sites More sharing options...
rberq Posted December 7, 2009 Report Share Posted December 7, 2009 Thank you , I will try your solution I found an other way but not as elegant! It is to convert T2 into integer witch keep only the digits, but this work for only 10 digits or 2,147,483,647 Max. Cool. I'll have to try that. So when you tell it to convert a string to an integer, it goes and finds the first string of digits and discards everything else? Quote Link to comment Share on other sites More sharing options...
guli34 Posted December 7, 2009 Author Report Share Posted December 7, 2009 Cool. I'll have to try that. So when you tell it to convert a string to an integer, it goes and finds the first string of digits and discards everything else? Here the code you may want to adjust the length of variable copy according to the URL I also add 2 extra variables just for debugging purpose. <IVAR2:06:01:35><ACTIVATE2:notepad><MMW2:853,53><MSD:%N6%><LCLK><MSD:%N6%><LCLK><MSD:%N6%><CLIPC><MSD:%N6%><REM2:copy the Url><TVAR2:01:03:><TMVAR2:09:05:01:000:000:><REM2:url copy again for the second #><TMVAR2:09:02:01:000:000:><IVAR2:10:13:1:dID><NMVAR:01:10:1:0000010:2:0000003><TMVAR2:11:02:00:001:N10:><TMVAR2:10:03:02:001:015:><TMVAR2:05:03:11:000:000:><NMVAR:05:11:0:0000003:0:0000000><TMVAR2:16:03:00:000:000:><ACTIVATE2:Microsoft Word><REM2:Paste the First #><CLIPP><IVAR2:12:13:5:geID=><NMVAR:01:12:1:0000012:2:0000004><TMVAR2:11:05:00:001:N12:><TMVAR2:16:05:00:000:000:><ACTIVATE2:Microsoft Word><REM2:Paste the second #><CLIPP> Quote Link to comment Share on other sites More sharing options...
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.