|
-
Jun 19th, 2003, 08:56 AM
#1
Thread Starter
Addicted Member
Parsing files....
hey guys its me again.
i want to write simple script which gets TXT file, which contains for example:
Hello world my name is Steave jones from canda,
i like dogs but i hate big ones...
now from these lines i want search all steave+space (Steave ) and to cut the first word after it.
any ideas?
thx.
-
Jun 19th, 2003, 04:45 PM
#2
You will need to use combination of Instr function and Mid function to search and cut the string.
Here is a simple example
VB Code:
Dim txt
txt = "Hello world my name is Steave jones from canda, like dogs but i hate big ones..."
Dim pos
Dim SearchWord
SearchWord = "steave "
pos = InStr(1, txt, SearchWord, vbTextCompare)
response.write Mid(txt, Len(SearchWord) + pos)
Hope this helps
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jun 20th, 2003, 03:31 AM
#3
Hyperactive Member
I would use an array to do this :
Code:
Dim TextString
TextString = "Hello world my name is Steave jones from canda, Steave jones likes dogs small dogs , "
TextString = TextString & "but Steave jones hates big ones... "
Dim WordArray
Dim SearchWord
SearchWord = "Steave"
WordArray = Split(TextString," ")
for i = 0 to UBound(WordArray)
if WordArray(i) = SearchWord and i < Ubound(WordArray) then
WordArray(i+1) = ""
i = i + 1
end if
next
TextString = join(WordArray," ")
response.write(TextString)
You can even add replace functionality easily :
Code:
Dim TextString
TextString = "Hello world my name is Steave jones from canda, Steave jones likes dogs small dogs , "
TextString = TextString & "but Steave jones hates big ones... "
Dim WordArray
Dim SearchWord
Dim ReplaceWord
SearchWord = "Steave"
ReplaceWord ="Smith"
WordArray = Split(TextString," ")
for i = 0 to UBound(WordArray)
if WordArray(i) = SearchWord and i < Ubound(WordArray) then
WordArray(i+1) = ReplaceWord
i = i + 1
end if
next
TextString = join(WordArray," ")
response.write(TextString)
--
Anglo Saxon
-
Jun 20th, 2003, 07:21 AM
#4
Thread Starter
Addicted Member
thx guys i hoe it work ill try it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|