473,511 Members | 15,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extract string before integer

6 New Member
hi all.

I got a urgent problem in my job.

the sample data as follows:

FT="EXERPRI:$68.88/10W*BB9505-28765710"
FT="MEETON6/3/07FOR

What I need is to extract the string after the quote and before any punctuation or integer so my outcome can be like this:

EXERPRI
MEETON

I use the SQL query as follows

SELECT Left([freetext],InStr([freetext],isnumeric())-1) AS Expr1
FROM Feb;

but it doesn't work. What can I do? Thanks a lot!
Jun 13 '07 #1
8 2464
zadkiel
6 New Member
hi all

I got a urgent problem in my job.

the sample data as follows:

FT="EXERPRI:$68.88/10W*BB9505-28765710"
FT="MEETON6/3/07FOR

What I need is to extract the string after the quote and before any punctuation or integer so my outcome can be like this:

EXERPRI
MEETON

I use the SQL query as follows

SELECT Left([freetext],InStr([freetext],isnumeric())-1) AS Expr1
FROM Feb;

but it doesn't work. What can I do? Thanks a lot!
Jun 13 '07 #2
FishVal
2,653 Recognized Expert Specialist
hi all.

I got a urgent problem in my job.

the sample data as follows:

FT="EXERPRI:$68.88/10W*BB9505-28765710"
FT="MEETON6/3/07FOR

What I need is to extract the string after the quote and before any punctuation or integer so my outcome can be like this:

EXERPRI
MEETON

I use the SQL query as follows

SELECT Left([freetext],InStr([freetext],isnumeric())-1) AS Expr1
FROM Feb;

but it doesn't work. What can I do? Thanks a lot!

Hi!

I can suggest the following.

Place the code below to a public module

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Text ' to make "a"="A" return true
  3.  
  4. Public Function ExtractLeftString(ByVal varInput) As Variant
  5.  
  6.     Dim intStringCursor As Integer, strChar As String
  7.  
  8.     If IsNull(varInput) Then Exit Function
  9.  
  10.     intStringCursor = 0
  11.  
  12.     Do
  13.         intStringCursor = intStringCursor + 1
  14.         strChar = Mid(varInput, intStringCursor, 1)
  15.     Loop While strChar >= "a" And strChar <= "z"
  16.  
  17.     ExtractLeftString = Left(varInput, intStringCursor - 1)
  18.  
  19. End Function
  20.  
  21.  
Pay attention to code row 1.

Now call this function from SQL query.

Good luck.
Jun 13 '07 #3
Lysander
344 Recognized Expert Contributor
hi all.

I got a urgent problem in my job.

the sample data as follows:

FT="EXERPRI:$68.88/10W*BB9505-28765710"
FT="MEETON6/3/07FOR

What I need is to extract the string after the quote and before any punctuation or integer so my outcome can be like this:

EXERPRI
MEETON

I use the SQL query as follows

SELECT Left([freetext],InStr([freetext],isnumeric())-1) AS Expr1
FROM Feb;

but it doesn't work. What can I do? Thanks a lot!
This function is quick and dirty but it works
Expand|Select|Wrap|Line Numbers
  1. Function Startstring(ByVal strInput As String) As String
  2.  
  3. Dim i As Integer, intStop As Integer, strChar As String
  4. intStop = 0
  5. For i = 1 To Len(strInput)
  6.     strChar = Mid(strInput, i, 1)
  7.     If Asc(strChar) > 122 Or Asc(strChar) < 65 Then 'Not A-z
  8.         'need to set intStop at the 1st time only
  9.         If intStop = 0 Then intStop = i
  10.     End If
  11. Next
  12. 'if intStop=0 then no bad chars
  13. 'if intStop=1 then all bad
  14. If intStop = 0 Then
  15.     Startstring = strInput
  16. ElseIf intStop = 1 Then
  17.     Startstring = ""
  18. Else
  19.     Startstring = Left(strInput, intStop - 1)
  20. End If
  21. End Function
  22.  
With a bit of time you can probaly put this in a do loop and exit the loop at the first non-alpha character
Jun 13 '07 #4
Lysander
344 Recognized Expert Contributor

Pay attention to code row 1.

Now call this function from SQL query.

Good luck.
Hi FishVal, guess we both answered the same problem at the same time. Your solution is neater though, like it.
Jun 13 '07 #5
r035198x
13,262 MVP
hi all.

I got a urgent problem in my job.

the sample data as follows:

FT="EXERPRI:$68.88/10W*BB9505-28765710"
FT="MEETON6/3/07FOR

What I need is to extract the string after the quote and before any punctuation or integer so my outcome can be like this:

EXERPRI
MEETON

I use the SQL query as follows

SELECT Left([freetext],InStr([freetext],isnumeric())-1) AS Expr1
FROM Feb;

but it doesn't work. What can I do? Thanks a lot!
@OP: Next time please don't double post.

Threads merged.
Jun 13 '07 #6
zadkiel
6 New Member
Thanks a lot but the result comes in this way:

FT
FT

it only captures FT...Frustrated


Hi!

I can suggest the following.

Place the code below to a public module

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Text ' to make "a"="A" return true
  3.  
  4. Public Function ExtractLeftString(ByVal varInput) As Variant
  5.  
  6.     Dim intStringCursor As Integer, strChar As String
  7.  
  8.     If IsNull(varInput) Then Exit Function
  9.  
  10.     intStringCursor = 0
  11.  
  12.     Do
  13.         intStringCursor = intStringCursor + 1
  14.         strChar = Mid(varInput, intStringCursor, 1)
  15.     Loop While strChar >= "a" And strChar <= "z"
  16.  
  17.     ExtractLeftString = Left(varInput, intStringCursor - 1)
  18.  
  19. End Function
  20.  
  21.  
Pay attention to code row 1.

Now call this function from SQL query.

Good luck.
Jun 14 '07 #7
zadkiel
6 New Member
oh I changed
intStringCursor = 5
then it works PERFECTLY WELL!!!!

THANKS A LOT!!!!!!!!!!

Thanks a lot but the result comes in this way:

FT
FT

it only captures FT...Frustrated
Jun 14 '07 #8
FishVal
2,653 Recognized Expert Specialist
oh I changed
intStringCursor = 5
then it works PERFECTLY WELL!!!!

THANKS A LOT!!!!!!!!!!
Glad it was helpful.

You should replace
intStringCursor = 5
with
intStringCursor = 4

otherwise
ExtractLeftString ("FT=""12312")
will return
FT="1
instead of
FT="

Code below is more universal.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Text ' to make "a"="A" return true
  3.  
  4. Public Function ExtractString(ByVal varInput As Variant, _
  5.                               Optional ByVal varStartSignature) As Variant
  6.  
  7.     Dim intStart As Integer, intStringCursor As Integer, strChar As String
  8.  
  9.     If IsNull(varInput) Then Exit Function
  10.  
  11.     If IsMissing(varStartSignature) Or IsNull(varStartSignature) Then
  12.         intStringCursor = 0
  13.     Else
  14.         intStringCursor = InStr(1, varInput, varStartSignature) + _
  15.                           Len(varStartSignature) - 1
  16.     End If
  17.  
  18.     intStart = intStringCursor + 1
  19.  
  20.     Do
  21.         intStringCursor = intStringCursor + 1
  22.         strChar = Mid(varInput, intStringCursor, 1)
  23.     Loop While strChar >= "a" And strChar <= "z"
  24.  
  25.     ExtractString = Mid(varInput, intStart, intStringCursor - intStart)
  26.  
  27. End Function
  28.  
  29.  
Example

? ExtractString("FT=""qwerty123", "FT=""")
qwerty
? ExtractString("AnyName=""qwerty123", "AnyName=""")
qwerty
? ExtractString("qwerty123")
qwerty

Good luck.
Jun 14 '07 #9

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

Similar topics

3
1765
by: Lauren Quantrell | last post by:
This a a long convoluted string parsing question... I have a string in an Access 2K database table field that I use for noting if a user has checked a record. The string goes like this: xy So...
6
10493
by: Mohammad-Reza | last post by:
Hi I want to extract icon of an exe file and want to know how. I look at the MSDN and find out that I can use ExtractIconEx() Windows API but in there are some changes to that api in c# I made...
4
2105
by: Barry | last post by:
How can I open a word doc and extract the text as text without any formatting characters?? -- Barry Fitzgerald
1
2077
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...
3
30760
by: Adam Faulkner via DotNetMonster.com | last post by:
I want to create a method within a class that opens a Microsoft Word 2000 Document and has the facility to Create a new word document and then extract a Page that exists within the original Word...
13
2701
by: Tony Girgenti | last post by:
Hello. Using VS.NET 2003 VB. If i have a string similar to the attached, how would i extract the "Truckname=" data from it in a loop and stay in the loop until the end of the string is reached...
4
2863
by: yinglcs | last post by:
Hi, how can I extract 2 integers from a string in python? for example, my source string is this: Total size: 173233 (371587) I want to extract the integer 173233 and 371587 from that...
7
3119
by: fool | last post by:
Dear group, Extract the integer value present in a given string. So I tried the following: int main(void) { int val; char *data; data = malloc(sizeof *data); if(data)
6
2091
by: Ben | last post by:
Hi We have a Dataset that has been populated from the output parameter of a Stored Procedure (@Output). I understand that I can extract a single item when the dataset is populated by a table...
0
7371
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
7432
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...
1
7093
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...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.