473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Running a query to extract substring

Hey thr!

I am in a fix please help me out.
Thing is i have extracted IP address now i want the substrings in parts. e.g.
if Ip address is 121.43.45.56 i want 121 , 43, 45 and 56 separately. how shud i go about it.

I tried for substring_index but wasnt successful.

waiting fr reponse....
thanks
Sep 26 '06 #1
2 4756
PEB
1,418 Expert 1GB
Hi
Create module and add this function to it!

Expand|Select|Wrap|Line Numbers
  1. Function get_word(my_sentence, sep, word_N) As String
  2. Dim Result As Integer
  3. Dim my_str
  4. Dim my_word
  5. Result = 1
  6. 'Stop
  7. Do While InStr(1, my_str, sep) > 0
  8.     If Result = word_N Then
  9.         my_word = Mid(my_str, 1, InStr(1, my_str, sep) - 1)
  10.         get_word = my_word
  11.         Exit Function
  12.     End If
  13. Result = Result + 1
  14. my_str = Mid(my_str, InStr(1, my_str, sep) + 1, Len(my_str) - 1)
  15. Loop
  16.     If Result = word_N Then
  17.         my_word = my_str
  18.         get_word = my_word
  19.         Exit Function
  20.     End If
  21. get_word = ""
  22. End Function
  23.  
In your query

First:get_word([IP], ".", 1)
Second:get_word([IP], ".", 2)
Tird:get_word([IP], ".", 3)
And so on...

Have a nice day!

:)

Hey thr!

I am in a fix please help me out.
Thing is i have extracted IP address now i want the substrings in parts. e.g.
if Ip address is 121.43.45.56 i want 121 , 43, 45 and 56 separately. how shud i go about it.

I tried for substring_index but wasnt successful.

waiting fr reponse....
thanks
Sep 26 '06 #2
hey

thanks a lot for tht!


Hi
Create module and add this function to it!

Expand|Select|Wrap|Line Numbers
  1. Function get_word(my_sentence, sep, word_N) As String
  2. Dim Result As Integer
  3. Dim my_str
  4. Dim my_word
  5. Result = 1
  6. 'Stop
  7. Do While InStr(1, my_str, sep) > 0
  8.     If Result = word_N Then
  9.         my_word = Mid(my_str, 1, InStr(1, my_str, sep) - 1)
  10.         get_word = my_word
  11.         Exit Function
  12.     End If
  13. Result = Result + 1
  14. my_str = Mid(my_str, InStr(1, my_str, sep) + 1, Len(my_str) - 1)
  15. Loop
  16.     If Result = word_N Then
  17.         my_word = my_str
  18.         get_word = my_word
  19.         Exit Function
  20.     End If
  21. get_word = ""
  22. End Function
  23.  
In your query

First:get_word([IP], ".", 1)
Second:get_word([IP], ".", 2)
Tird:get_word([IP], ".", 3)
And so on...

Have a nice day!

:)
Sep 26 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tim Smith | last post by:
I am looking to extract form element values from html, more generally I have a substring that identifies the beginning of a value and a string that identifies the end of value and I need to extract...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
6
by: Rowland | last post by:
Hi, I've got a field that stores numeric values, representing a tracking number. I've also got a stored procedure that will extract this field and return it to a client. However, I would like to...
4
by: rdraider | last post by:
Is there a function that will extract part of a string when the data you want does not occur in a specific position? Field "REF" is varchar(80) and contains an email subject line and the email...
9
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and...
3
by: jarod1701 | last post by:
Hi, I'm currently trying to create a regular expression that can extract certain elements from a url. The url will be of the following form: http://user:pass@www.sitename.com I want a...
1
by: Nick | last post by:
Hi, I'm trying to extract element of a directory path stored in the db with substring "/help/support/index/time.jsp" and i want to extract the 1st, 2nd and 3rd parts 1st = help, 2nd =...
1
by: Patrick Sullivan | last post by:
I am trying to extract two parts of a number from an array element. Numbers are in the format of 1.10, 2.50, 11.10, etc. Floor and ceiling won't work right because close to 1.00, I get a zero, and...
1
by: charvi | last post by:
Hi i have problem in query to extract a sub string from a string that is i want to extract first name from name for eg if i have a name John Smith i want to extract John how to extract this can...
2
by: Dean g | last post by:
Hi, I'm trying to use the result from the select within the same query. See code SELECT accountnum, char(ASCII(SUBSTRING(accountnum, 1, 1))) as firstChar from questions where firstchar='m' ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.