This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / A Small VB Question (post again)I have bunch of telephone numbers like this
1-416-123*-887-*9877@888-99908
one thing I'm sure is before 416- is area code and
after the final dash, it's extention.
it's transfered from a legacy system and I got only a
txt file contians all these numbers.
what I want to do is to keep area code and extention,
replace last "-" with "ext", remove all non-numeric
characters in the middle,any easy way in VB to solve it?
-interview(intervieweree);
2002-2-12
{441}
(#366742@0)
-
1,regular express, (best) 2, or a) find how many\" -\"; b) deal with it (break and combine it).
-fraserbank(mike);
2002-2-12
(#366827@0)
-
figure it out. Thank you. And thanks everyone who contributes his/her timeSet regEx = New RegExp
sVariable = "416-1@rfr4535ef34hb-653yuyue904537 73--39 hbhg324-789"
regEx.Global = True
regEx.Pattern = "^(\d+-)(.*)(-\d+)$"
Set oMatches = regEx.Execute(sVariable)
regEx.Pattern = "\D"
sNewVariable = oMatches(0).SubMatches(0) & regEx.Replace(oMatches(0).SubMatches(1), "") & Replace(oMatches(0).SubMatches(2), "-", "ext")
-interview(intervieweree);
2002-2-12
{366}
(#366886@0)
-
7 lines code, no loop. great
-interview(intervieweree);
2002-2-12
(#366887@0)
-
actually, it is an interview question, hope my answer helps when you guys meet thi squestion again in your interview
-interview(intervieweree);
2002-2-12
(#366889@0)
-
1,regular express, (best) 2, or a) find how many\" -\"; b) deal with it (break and combine it).
-fraserbank(mike);
2002-2-12
(#366828@0)