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 Today, 08:37 AM
Post#1



Posts: 4
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 Today, 08:41 AM
Post#2



Posts: 2,012
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 Today, 08:57 AM
Post#3



Posts: 4
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: Today, 09:02 AM
Go to the top of the page
 
orange999
post Today, 09:43 AM
Post#4



Posts: 2,012
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: Today, 09:45 AM

--------------------
Good luck with your project!
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    25th January 2020 - 02:29 PM