UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Vbscript Regular Expressions, VBScript_RegExp_55    
 
   
joeDeuce
post Yesterday, 08:37 AM
Post#1



Posts: 5
Joined: 31-July 19



Using RegExp from VBScript_RegExp_55 I currently use the following expression, which works but takes 20 seconds to compare against only 650 strings:
CODE
oRe.Pattern = "([A-Z\-]+), ([A-Z]+[ ][A-Z]*) +[A-Z \-,.]*([\d]+) *\w*[A-Z \-,./\d]* ([\d]+)-[NSEW]-([\d]+)"


An example string (with ^ underneath to show what I'm trying to capture) is:
CODE
GRIFFIN, PETER JOHN            456456       MEDIUM              CLARK-SMITH, T.               03/12/1999   WHITE       14-W-23-T
^^^^^^^  ^^^^^^^^^^            ^^^^^^                                                                                  ^^   ^^


I'll gladly admit this is my first use of regular expressions. Does anything stand out that can either be simplified or optimized?


Go to the top of the page
 
orange999
post Yesterday, 08:41 AM
Post#2



Posts: 2,013
Joined: 10-February 08
From: Ottawa, Ont, Canada; West Palm Beach, FL


Joe,
Can you give an example of an original string and the result you need?

--------------------
Good luck with your project!
Go to the top of the page
 
joeDeuce
post Yesterday, 08:57 AM
Post#3



Posts: 5
Joined: 31-July 19



In the example string
CODE
"GRIFFIN, PETER JOHN            456456       MEDIUM              CLARK-SMITH, T.               03/12/1999   WHITE       14-W-23-T"
I'm using a MatchCollection with the regular expression
CODE
"([A-Z\-]+), ([A-Z]+[ ][A-Z]*) +[A-Z \-,.]*([\d]+) *\w*[A-Z \-,./\d]* ([\d]+)-[NSEW]-([\d]+)"
to grab
CODE
"GRIFFIN"
"PETER JOHN"
"456456"
"14"
"23"
as 5 strings so that I can import into the db. Does VBScript RegExp not have a $ to match end of string? If so I should be able to greatly simplify the regexp
This post has been edited by joeDeuce: Yesterday, 09:02 AM
Go to the top of the page
 
orange999
post Yesterday, 09:43 AM
Post#4



Posts: 2,013
Joined: 10-February 08
From: Ottawa, Ont, Canada; West Palm Beach, FL


Joe,

How consistent is the format of your input strings? Fixed length? Are the "spaces" really spaces (32) or Tabs?
Is the exercise to do this with regex, or are other approaches OK?
This post has been edited by orange999: Yesterday, 09:45 AM

--------------------
Good luck with your project!
Go to the top of the page
 
joeDeuce
post Today, 02:58 PM
Post#5



Posts: 5
Joined: 31-July 19



They are actually spaces.

I don't have to use regex, I just have to get the data into a table. Unfortunately, the file being imported has lines that don't need to be imported... below is an example (with dummy data):
CODE
XX DEPT OF CORRECTIONS                                MOOMOO STATE PRISON                           Date Printed: 07/12/2019 08:49:38 AM
Alpha Roster                                                                                                     Printed By: DOE, RHONDA
                                                                                                                            Page 1 of 13

Name                              DOC ID      Security            Case Manager     MH Level     Birth Date   Race        Bed

AGAPE, WILLIAM                    1014189     MEDIUM              LEWIS, H.                     11/21/1987   WHITE       6-S-52-B
ABERN, GARY PAUL                  642534      MINIMUM             WHITTEN, A.                   10/11/1956   WHITE       7-N-6-T
ACHO, JESSE                       761938      MEDIUM              WHITTEN, A.                   05/22/1966   BLACK       3-W-36-T
ACKERS, ANTHONY                   1002256887  STANDARD            LONG-STROH, P                 07/12/1980   WHITE       9-E-36-T
ADAMSON, ALVIN                    995634      MEDIUM              HORNER, D.                    09/01/1969   BLACK       1-N-1-B

The file is one long text file that has been converted from pdf. If there is a more efficient way to get the data imported, I'm all for it!

Thanks so much for your help!
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    26th January 2020 - 03:29 PM