Is it possible for a regular expression to macth only an empty string? What
I want is exactly {0}, but that causes the parser to throw an exception -
parsing "{0}" - Quantifier {x,y} following nothing.
Duh, I want nothing. Maybe I need an expression that evaluates to "not
anything?" I can't find that either.
Paul 7 5873
On May 1, 8:23 am, "PJ6" <n...@nowhere.netwrote:
Is it possible for a regular expression to macth only an empty string? What
I want is exactly {0}, but that causes the parser to throw an exception -
parsing "{0}" - Quantifier {x,y} following nothing.
Duh, I want nothing. Maybe I need an expression that evaluates to "not
anything?" I can't find that either.
Paul
Just to make sure I know what you're asking, could you provide the
string you are searching and exactly what you want returned?
For example:
In the string "This is a sentence "{0}" that has the target phrase
in it."
The regex pattern "(?<=\{).*(?=\})" will return just the character
0.
The regex pattern "(?<="").*(?="")" will return {0}
If this isn't what you are looking for I need that extra info I
mentioned above.
Thanks,
Seth Rowe
PJ6 wrote:
Is it possible for a regular expression to macth only an empty
string?
In what context? Why aren't
if stringVar is nothing then...
or
if Len(stringVar)=0 then...
sufficient?
What I want is exactly {0}, but that causes the parser to
throw an exception -
parsing "{0}" - Quantifier {x,y} following nothing.
Surely you would want exactly 1 nothing, not zero nothings?
Andrew
>What I want is exactly {0}, but that causes the parser to
>throw an exception - parsing "{0}" - Quantifier {x,y} following nothing.
Surely you would want exactly 1 nothing, not zero nothings?
I tend to agree.
If you want to detect empty strings (ie nothing) then regular expressions
seem like overkill.
The best method I would advise would be...
-------------------------------------------------------------
Myvar = String.Empty
-------------------------------------------------------------
This will also check for string = Nothing
--
Rory
I'm working with a validator that takes a regular expression string. I need
it to accept a certin range of values, or a completely empty value. I use |
for the OR condition. I now believe it is difficult, if not impossible, to
create a regular expresion that _only_ matches "", the empty string.
Paul
<enwrote in message
news:b0*************************@msnews.microsoft. com...
>>What I want is exactly {0}, but that causes the parser to throw an exception - parsing "{0}" - Quantifier {x,y} following nothing.
Surely you would want exactly 1 nothing, not zero nothings?
I tend to agree.
If you want to detect empty strings (ie nothing) then regular expressions
seem like overkill.
The best method I would advise would be...
-------------------------------------------------------------
Myvar =
String.Empty -------------------------------------------------------------
This will also check for string = Nothing
--
Rory
On May 2, 11:43 am, "PJ6" <n...@nowhere.netwrote:
I'm working with a validator that takes a regular expression string. I need
it to accept a certin range of values, or a completely empty value. I use |
for the OR condition. I now believe it is difficult, if not impossible, to
create a regular expresion that _only_ matches "", the empty string.
Paul
<enwrote in message
news:b0*************************@msnews.microsoft. com...
>What I want is exactly {0}, but that causes the parser to throw an exception - parsing "{0}" - Quantifier {x,y} following nothing.
Surely you would want exactly 1 nothing, not zero nothings?
I tend to agree.
If you want to detect empty strings (ie nothing) then regular expressions
seem like overkill.
The best method I would advise would be...
-------------------------------------------------------------
Myvar =
String.Empty -------------------------------------------------------------
This will also check for string = Nothing
--
Rory
I'm working with a validator that takes a regular expression string
Is this a Asp.Net project?
Thanks,
Seth Rowe
Is this a Asp.Net project?
>
Thanks,
Seth Rowe
Ha ha ha. Yes, you got me. I discovered shortly after I posed the question
that the pattern validator isn't even called when the control to be
validated is empty, and I had forgotten to remove a RequiredFieldValidator,
which immediately solved my problem.
So the question as it stands now is purely academic.
;)
Paul
PJ6 wrote:
So the question as it stands now is purely academic.
And easy to solve. Match whatever you want zero or one times. The
pattern "^(\d{4})?$" for example matches either four digits or an empty
string.
--
Göran Andersson
_____ http://www.guffa.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Vibha Tripathi |
last post by:
Hi Folks,
I put a Regular Expression question on this list a
couple days ago. I would like to rephrase my question
as below:
In the Python re.sub(regex, replacement, subject)...
|
by: Bradley Plett |
last post by:
I'm hopeless at regular expressions (I just don't use them often
enough to gain/maintain knowledge), but I need one now and am looking
for help. I need to parse through a document to find a URL,...
|
by: Lee Kuhn |
last post by:
I am trying the create a regular expression that will essentially match
characters in the middle of a fixed-length string. The string may be any
characters, but will always be the same length. In...
|
by: Q. John Chen |
last post by:
I have Vidation Controls
First One: Simple exluce certain special characters:
say no a or b or c in the string:
*
Second One:
I required date be entered in "MM/DD/YYYY" format:
//+4 How...
|
by: Ryan |
last post by:
HELLO
I am using the following MICROSOFT SUGGESTED (somewhere on msdn)
regular expression to validate email addresses however I understand
that the RFP allows for "+" symbols in the email address...
|
by: norton |
last post by:
Hello,
Does any one know how to extact the following text into 4 different
groups(namely Date, Artist, Album and Quality)?
- Artist - Album
Artist - Album
- Artist - Album
- Artist -...
|
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I...
|
by: Ludwig |
last post by:
Hi,
i'm using the regular expression \b\w to find the beginning of a word,
in my C# application. If the word is 'public', for example, it works.
However, if the word is '<public', it does not...
|
by: Zach |
last post by:
Hello,
Please forgive if this is not the most appropriate newsgroup for this
question. Unfortunately I didn't find a newsgroup specific to regular
expressions.
I have the following regular...
|
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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: 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
| |