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

regex result question

gs
is it OK to get regex result of pattern which has duplicate reference names
like
StrDatePattern As String
="\b(((?<year>\d{4})-(?<month>\d{1,2})-(?<day>\d{2}))|{(?<month>\d{1,2})
(?<day>\d{2}), (?<year>\d{4})))"?

my code segment
StrDatePattern As String
="\b(((?<year>\d{4})-(?<month>\d{1,2})-(?<day>\d{2}))|{(?<month>\d{1,2})
(?<day>\d{2}), (?<year>\d{4})))"?
Dim strDate As String = "", _
strYMD As String = ""

Dim r as regex = New Regex(StrDatePattern , RegexOptions.IgnoreCase)
Dim m as match = r.Match(myStringHoldingDateInfo)
If m.Success Then
al_posn = m.Index + 1
strDate = Mid(StringIn, al_posn, m.Length) ' works so far
strYMD = m.Result("${year)-${month}-{$day}") ' at best, I
get the year component only
Else
al_posn = 0
strDate = ""
strYMD = ""
End If

I did not have much luck using match.result to re-arrange the extracted date
string. However I was able to extract the matched date string.
I even try with another match on strYMD and then use that result to
re-arrange
the date string and still no luck.
What did I go wrong?

thank you for your time.

Nov 21 '05 #1
1 1032
On 2005-09-04, gs <gs@nomail.nil> wrote:
is it OK to get regex result of pattern which has duplicate reference names
Yes...
like
StrDatePattern As String
="\b(((?<year>\d{4})-(?<month>\d{1,2})-(?<day>\d{2}))|{(?<month>\d{1,2})
(?<day>\d{2}), (?<year>\d{4})))"?
That doesn't compile. What's the '{' character right after the pipe
supposed to do? Regexes get so dense that it's important to copy and
paste the pattern into your post rather than retype it. The smallest
mistake can make your question impossible to answer.

It seems that you want a '(' rather than a '{' there, but that means
you're trying match strings like "12 23, 2005". That's possible, but it
seems like a strange date format.

my code segment
....
Dim m as match = r.Match(myStringHoldingDateInfo)


The obvious question here is what is the input string you're trying to
match. Without that information, it's hard to know what the problem
is.
Nov 21 '05 #2

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

Similar topics

4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
2
by: GS | last post by:
How can one avoid capturing leading empty or blank lines? the data I deal with look like this "will be paid on the dates you specified. xyz supplier amount: $100.52 when: September 07,...
0
by: Karch | last post by:
I have these two methods that are chewing up a ton of CPU time in my application. Does anyone have any suggestions on how to optimize them or rewrite them without Regex? The most time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.