Could anyone tell me why the following do not match?
^ABC_\d{6}_\d{6}$
Should match(twice):
ABC_123456_789123
ABC_123456_789123
It matches:
ABC_123456_789123
But not the double one.
Regex options set are:
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace |
RegexOptions.Multiline
TIA
JB 6 1261
John B wrote:
Could anyone tell me why the following do not match?
^ABC_\d{6}_\d{6}$
Should match(twice):
ABC_123456_789123
ABC_123456_789123
It matches:
ABC_123456_789123
But not the double one.
Regex options set are:
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace |
RegexOptions.Multiline
If I read your description correct, then it does more sound as
a problem with the code retrieving matches than with the regex.
Try post the code.
Arne
Hi John,
I may be wrong, but from my experience, if it was to match your double item,
it should be (^ABC_\d{6}_\d{6}$)+
meaning that it would allow that whole pattern one or more times as opposed
to just once.
- Lucas
"John B" <jb******@yahoo.comwrote in message news:fn**********@aioe.org...
Could anyone tell me why the following do not match?
^ABC_\d{6}_\d{6}$
Should match(twice):
ABC_123456_789123
ABC_123456_789123
It matches:
ABC_123456_789123
But not the double one.
Regex options set are:
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace |
RegexOptions.Multiline
TIA
JB
Lucas Eagleton wrote:
Hi John,
I may be wrong, but from my experience, if it was to match your double
item, it should be (^ABC_\d{6}_\d{6}$)+
meaning that it would allow that whole pattern one or more times as
opposed to just once.
Hmm, I was under the impression that it would match _any_ instances
(only the *and+ operators being greedy and eating the other matches
would interfere).
I am by no means an expert though and I tried the grouped one or more
and it still didnt work.
I eventually used (?:^|\r|\n)(?<asn>abc_\d{6}_\d{6})(?:$|\r|\n) which
worked, see reply to Arne for more.
Thanks for your help.
John
- Lucas
"John B" <jb******@yahoo.comwrote in message
news:fn**********@aioe.org...
>Could anyone tell me why the following do not match?
^ABC_\d{6}_\d{6}$
Should match(twice):
ABC_123456_789123 ABC_123456_789123
It matches: ABC_123456_789123
But not the double one.
Regex options set are:
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline
TIA
JB
John B wrote:
Arne Vajhøj wrote:
>A bit of experimentation shows that:
matcher.Matches("ABC_123456_789123\nABC_123456_78 9123")
will find 2 matches.
But it is not obvious to me why \n is the proper line delimiter and not \r\n.
Maybe someone with more regex knowledge than me can explain it.
Ahh, I see.
Hmm, that is kind of odd, I would have thought the system "New Line"
variable would be used (\r\n for windows obviously)
Me too.
But ...
Arne
On Jan 21, 1:42 am, John B <jbngs...@yahoo.comwrote:
Lucas Eagleton wrote:
Hi John,
I may be wrong, but from my experience, if it was to match your double
item, it should be (^ABC_\d{6}_\d{6}$)+
meaning that it would allow that whole pattern one or more times as
opposed to just once.
Hmm, I was under the impression that it would match _any_ instances
(only the *and+ operators being greedy and eating the other matches
would interfere).
yes + and * are greedy but you can make them not greedy by appending
a ? like this:
new Regex("#.+?#") matched against "#hello # world#" would give
"#hello #"
while new Regex(".+") would return the match "#hello # world#"
hth,
-- henon
-------------- http://www.eqqon.com/index.php/User:Henon
On Jan 21, 12:10 pm, henon <meinrad.rech...@gmail.comwrote:
while new Regex(".+") would return the match "#hello # world#"
correction: while new Regex("#.+#") would return the match "#hello #
world#" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: alphatan |
last post by:
Is there relative source or document for this purpose?
I've searched the index of "Mastering Regular Expression", but cannot
get the useful information for C.
Thanks in advanced.
--
Learning...
|
by: Tim Conner |
last post by:
Is there a way to write a faster function ?
public static bool IsNumber( char Value )
{
if (Regex.IsMatch( Value.ToString(), @"^+$" ))
{
return true;
}
else return false;
}
|
by: Jose |
last post by:
There's something for me to learn with this example, i'm sure :)
Given this text:
"....."
and my first attempt at capture the groups:
"(?:\)"
RegExTest gives me what i expect: 6 captured...
|
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
...
|
by: Chris |
last post by:
How Do I use the following auto-generated code from The Regulator?
'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated...
|
by: Bob |
last post by:
I need to create a Regex to extract all strings (including quotations) from
a C# or C++ source file. After being unsuccessful myself, I found this
sample on the internet:
...
|
by: Martin Evans |
last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get
a regular expression to do the following example in Python:
Search and replace all instances of "sleeping" with "dead"....
|
by: morleyc |
last post by:
Hi, i would like to remove a number of characters from my string (\t
\r \n which are throughout the string), i know regex can do this but i
have no idea how. Any pointers much appreciated.
Chris
|
by: Mark Chambers |
last post by:
Hi there,
I'm seeking opinions on the use of regular expression searching. Is there
general consensus on whether it's now a best practice to rely on this rather
than rolling your own (string)...
|
by: nagar |
last post by:
I need to split a string whenever a separator string is present (lets
sey #Key(val) where val is a variable) and rejoin it in the proper
order after doing some processing.
Is there a way to use...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |