I searched on line help but I did not see anything about assigning string
literals en mass to an array.
is there such construct like
Dim mystrs()
mystrs = {"element1", "ele2", "e3"}
instead of something devious ; like
Const YEAR_NAME = "year"
Const MONTH_NAME = "month"
Const DAY_NAME = "day"

YEARRef = "?<" & YEAR_NAME & ">"
MONTHRef = "?<" & MONTH_NAME & ">"
DAYRef = "?<" & DAY_NAME & ">"

YEARPart = "$(" & YEAR_NAME & ")"
MONTHPart = "$(" & MONTH_NAME & ")"
DAYPart = "$(" & DAY_NAME & ")"

Const DatePart_yy = "(1[7-9]|[23][0-9])[0-9][0-9]"
Const DatePart_y = "d{2}"
DatePart_Year = DatePart_yy & "|" & DatePart_y '
"(([1[7-9])|([23][0-9])){0,1}[0-9][0-9]|[0-9][0-9]"

Const DatePart_mmm =
"JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER"
Const DatePart_m = "10|11|12|0{0,1}[1-9]"
DatePart_Month = DatePart_mmm & "|" & DatePart_m

Const DatePart_d = "31|30|0{0,1}[1-9]|[12][0-9]"

DatePatrn_d = "(" & DAYRef & DatePart_d & ")"

DatePatrn_mmm = "(" & MONTHRef & DatePart_mmm & ")"
DatePatrn_m = "(" & MONTHRef & DatePart_m & ")"
DatePatrn_month = "(" & MONTHRef & DatePart_mmm & "|" & DatePart_m &
")"

DatePatrn_y = "(" & YEARRef & DatePart_y & ")" ' 19 something thru
30xx
DatePatrn_yy = "(" & YEARRef & DatePart_yy & ")"
DatePatrn_year = "(" & YEARRef & DatePart_Year & ")"
'0 m/d/Year
'1 M d, Y
'2 d mmm yy
'3 y-M-d
'4 y.M.d
'5 yy/m/d

DATE_PatternsString = "(" & DatePatrn_m & "/" & DatePatrn_d & "/" &
DatePatrn_year & ")(?=\s)#" & _
"\b(" & DatePatrn_Month & " " & DatePatrn_d & ", " & DatePatrn_year
& ")(?= )#" & _
"\b(" & DatePatrn_d & " " & DatePatrn_mmm & " " & DatePatrn_Year &
")(?=\s)#" & _
"\b(" & DatePatrn_Year & "-" & DatePatrn_Month & "-" & DatePatrn_d &
")(?=\s)#" & _
"\b(" & DatePatrn_Year & "\." & DatePatrn_Month & "\." & DatePatrn_d
& ")(?=\s)#" & _
"\b(" & DatePatrn_yy & "/" & DatePatrn_m & "/" & DatePatrn_d &
")(?=\s)"
Dim DATE_Patterns
DATE_Patterns = Split("\b" &DATE_PatternsString, "#")

the 1st form does not work for vbscript ( I don't think it work for VB.net
either. The devious way of splitting works

Re: string array initial value assignment by Michael

Michael
Sat Sep 10 18:07:57 CDT 2005

jg wrote:
> I searched on line help but I did not see anything about assigning
> string literals en mass to an array.
> is there such construct like
> Dim mystrs()
> mystrs = {"element1", "ele2", "e3"}

Dim mystrs
mystrs = Array("element1", "ele2", "e3")

or

Dim mystrs
mystrs = Split("element1,ele2,e3", ",")


> instead of something devious ; like
> Const YEAR_NAME = "year"
> Const MONTH_NAME = "month"
> Const DAY_NAME = "day"
>
> YEARRef = "?<" & YEAR_NAME & ">"
> MONTHRef = "?<" & MONTH_NAME & ">"
> DAYRef = "?<" & DAY_NAME & ">"
>
> YEARPart = "$(" & YEAR_NAME & ")"
> MONTHPart = "$(" & MONTH_NAME & ")"
> DAYPart = "$(" & DAY_NAME & ")"
>
> Const DatePart_yy = "(1[7-9]|[23][0-9])[0-9][0-9]"
> Const DatePart_y = "d{2}"
> DatePart_Year = DatePart_yy & "|" & DatePart_y '
> "(([1[7-9])|([23][0-9])){0,1}[0-9][0-9]|[0-9][0-9]"
>
> Const DatePart_mmm =
> "JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER"
> Const DatePart_m = "10|11|12|0{0,1}[1-9]"
> DatePart_Month = DatePart_mmm & "|" & DatePart_m
>
> Const DatePart_d = "31|30|0{0,1}[1-9]|[12][0-9]"
>
> DatePatrn_d = "(" & DAYRef & DatePart_d & ")"
>
> DatePatrn_mmm = "(" & MONTHRef & DatePart_mmm & ")"
> DatePatrn_m = "(" & MONTHRef & DatePart_m & ")"
> DatePatrn_month = "(" & MONTHRef & DatePart_mmm & "|" &
> DatePart_m & ")"
>
> DatePatrn_y = "(" & YEARRef & DatePart_y & ")" ' 19 something
> thru 30xx
> DatePatrn_yy = "(" & YEARRef & DatePart_yy & ")"
> DatePatrn_year = "(" & YEARRef & DatePart_Year & ")"
> '0 m/d/Year
> '1 M d, Y
> '2 d mmm yy
> '3 y-M-d
> '4 y.M.d
> '5 yy/m/d
>
> DATE_PatternsString = "(" & DatePatrn_m & "/" & DatePatrn_d & "/" &
> DatePatrn_year & ")(?=\s)#" & _
> "\b(" & DatePatrn_Month & " " & DatePatrn_d & ", " &
> DatePatrn_year & ")(?= )#" & _
> "\b(" & DatePatrn_d & " " & DatePatrn_mmm & " " &
> DatePatrn_Year & ")(?=\s)#" & _
> "\b(" & DatePatrn_Year & "-" & DatePatrn_Month & "-" &
> DatePatrn_d & ")(?=\s)#" & _
> "\b(" & DatePatrn_Year & "\." & DatePatrn_Month & "\." &
> DatePatrn_d & ")(?=\s)#" & _
> "\b(" & DatePatrn_yy & "/" & DatePatrn_m & "/" & DatePatrn_d &
> ")(?=\s)"
> Dim DATE_Patterns
> DATE_Patterns = Split("\b" &DATE_PatternsString, "#")
>
> the 1st form does not work for vbscript ( I don't think it work for
> VB.net either. The devious way of splitting works

--
Michael Harris
Microsoft MVP Scripting