473,396 Members | 2,129 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,396 software developers and data experts.

Search text

I try to search pattern using RegExp method but it wont work. Data
contain emails which i save it into a textfile and want to read the
contents of email (Date, Customer Name, Street, Subject etc etc). Date,
Customer Name etc they all are in large braket and on the next line
their description is available. Needs help how to i read the word Date,
Customer Name etc and then fetch the next line record.

Dim fso, fil, ts, sContents
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fil = fso.getfile(server.mappath("myemails.txt"))
Set ts = fil.openastextstream(1)
sContents = ts.readall
dim strPatternString as String
strPatternString = "\s\S"
sPattern = "Street\:\s*([" & strPatternString & "]+?)[\r\n]+"
Dim rx
Set rx = New RegExp
rx.Global = True
rx.IgnoreCase = True
rx.MultiLine = True
rx.Pattern = sPattern
Set mc = rx.Execute(sContents)
For Each rm In mc
sFrom = rm.SubMatches(0)
response.write("<br>")
response.write(sFrom)
Next
ts.close
Set rx = nothing
Set ts = nothing
Set fil = nothing
Set fso = nothing
---------------SAMPLE DATA---------------
[Date]
Wed Aug 02 10:29:18 EDT 2006
[Novell ID]
EZARDOYA
[Subject]
Research - 885031
[Customer's Name]
SIMONE LERINA
[Street]
44 ELIZABETH AVE APT BSMT
[City, State, Zip]

Aug 8 '06 #1
1 1026
Here's an easier approach. Doesn't use RegularExpressions, but it works just
as well:

1) Create an instance of a System.IO.StreamReader, specifying the file
2) Create a loop that calls ReadLine

(ReadLine returns a string that represents the entire line of text. You can
chech the returned value to see if the line was "[Date]" "[Subject]" or
whatever...then call Readline again to get teh actual Data.
"Eric" wrote:
I try to search pattern using RegExp method but it wont work. Data
contain emails which i save it into a textfile and want to read the
contents of email (Date, Customer Name, Street, Subject etc etc). Date,
Customer Name etc they all are in large braket and on the next line
their description is available. Needs help how to i read the word Date,
Customer Name etc and then fetch the next line record.

Dim fso, fil, ts, sContents
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fil = fso.getfile(server.mappath("myemails.txt"))
Set ts = fil.openastextstream(1)
sContents = ts.readall
dim strPatternString as String
strPatternString = "\s\S"
sPattern = "Street\:\s*([" & strPatternString & "]+?)[\r\n]+"
Dim rx
Set rx = New RegExp
rx.Global = True
rx.IgnoreCase = True
rx.MultiLine = True
rx.Pattern = sPattern
Set mc = rx.Execute(sContents)
For Each rm In mc
sFrom = rm.SubMatches(0)
response.write("<br>")
response.write(sFrom)
Next
ts.close
Set rx = nothing
Set ts = nothing
Set fil = nothing
Set fso = nothing
---------------SAMPLE DATA---------------
[Date]
Wed Aug 02 10:29:18 EDT 2006
[Novell ID]
EZARDOYA
[Subject]
Research - 885031
[Customer's Name]
SIMONE LERINA
[Street]
44 ELIZABETH AVE APT BSMT
[City, State, Zip]

Aug 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Phlip | last post by:
C++ers: Here's an open ended STL question. What's the smarmiest most templated way to use <string>, <algorithms> etc. to turn this: " able search baker search charlie " into this: " able...
8
by: Huihong | last post by:
Please check out our newly released source code search engine here, http://www.codase.com e.g., search socket method call,...
5
by: Martien van Wanrooij | last post by:
I have been using phpdig in some websites but now I stored a lot of larger texts into a mysql database. In the phpdig search engine, when you entered a search word, the page where the search word...
10
by: wo_shi_big_stomach | last post by:
Newbie to python writing a script to recurse a directory tree and delete the first line of a file if it contains a given string. I get the same error on a Mac running OS X 10.4.8 and FreeBSD 6.1. ...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
13
by: Robertf987 | last post by:
Hi, Yet another thing I need help with I'm affraid. I'll first explain what I want, then I'll try to explain what I have. I'm using Microsoft Access 2000. What I want is to be able to do a...
3
by: =?Utf-8?B?UGVycmlud29sZg==?= | last post by:
Not sure where to post this... Found some interesting behavior in Windows Search (Start =Search =All files and folders =search for "A word or phrase in the file:"). This applies to XP and maybe...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...

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.