473,396 Members | 1,891 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,396 software developers and data experts.

Regex- Is there an IIF equivalent?

I'm using the following code to extract a number, upto 3 digits long, from a
web page:

Dim str2Find As String = ">(\d{0,3}|&nbsp;)<"

Dim regNumReplies As New RegularExpressions.Regex( _

str2Find, Options:=RegularExpressions.RegexOptions.Singlelin e)

Return regNumReplies.Matches(str, str2Find).Item(0).Groups(1).ToString

If the number does not exist, it returns "&nbsp;". Is there a way, using
RegEx, to return either the digits found, or if "&nbsp;" is found, return
"0"?
--
|
+-- Thief_
|
Nov 21 '05 #1
2 1108
Hi,

Maybe you could use an IIF with regnumreplies.ismatch.

http://msdn.microsoft.com/library/de...atchtopic1.asp

Ken
---------------
"Thief_" <th****@hotmail.com> wrote in message
news:uD****************@TK2MSFTNGP14.phx.gbl...
I'm using the following code to extract a number, upto 3 digits long, from a
web page:

Dim str2Find As String = ">(\d{0,3}|&nbsp;)<"

Dim regNumReplies As New RegularExpressions.Regex( _

str2Find, Options:=RegularExpressions.RegexOptions.Singlelin e)

Return regNumReplies.Matches(str, str2Find).Item(0).Groups(1).ToString

If the number does not exist, it returns "&nbsp;". Is there a way, using
RegEx, to return either the digits found, or if "&nbsp;" is found, return
"0"?
--
|
+-- Thief_
|

Nov 21 '05 #2
That solution will not work because the outcome of the IsMatch property will
be true if either a number or "&nbsp;" is found. I think, for now at least,
I'll add a VB.NET IIF in the next line to change the value.

I just thought it would be cool to do it all in RegEx. Thanks.

--
|
+-- Thief_
|

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
Hi,

Maybe you could use an IIF with regnumreplies.ismatch.

http://msdn.microsoft.com/library/de...atchtopic1.asp
Ken
---------------
"Thief_" <th****@hotmail.com> wrote in message
news:uD****************@TK2MSFTNGP14.phx.gbl...
I'm using the following code to extract a number, upto 3 digits long, from a web page:

Dim str2Find As String = ">(\d{0,3}|&nbsp;)<"

Dim regNumReplies As New RegularExpressions.Regex( _

str2Find, Options:=RegularExpressions.RegexOptions.Singlelin e)

Return regNumReplies.Matches(str, str2Find).Item(0).Groups(1).ToString

If the number does not exist, it returns "&nbsp;". Is there a way, using
RegEx, to return either the digits found, or if "&nbsp;" is found, return
"0"?
--
|
+-- Thief_
|

Nov 21 '05 #3

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

Similar topics

3
by: Alan Pretre | last post by:
Can anyone help me figure out a regex pattern for the following input example: xxx:a=b,c=d,yyy:e=f,zzz:www:g=h,i=j,l=m I would want four matches from this: 1. xxx a=b,c=d 2. yyy e=f 3....
3
by: Jeff McPhail | last post by:
I am using Regex.Match in a large application and the memory is growing out of control. I have tried several ways to try and release the memory and none of them work. Here are some similar examples...
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 ...
5
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated...
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
3
by: aspineux | last post by:
My goal is to write a parser for these imaginary string from the SMTP protocol, regarding RFC 821 and 1869. I'm a little flexible with the BNF from these RFC :-) Any comment ? tests= def...
15
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
1
by: jonnyboy6969 | last post by:
Hi All Really hoping someone can help me out here with my deficient regex skills :) I have a function which takes a string of HTML and replaces a term (word or phrase) with a link. The pupose...
4
by: CJ | last post by:
Is this the format to parse a string and return the value between the item? Regex pRE = new Regex("<File_Name>.*>(?<insideText>.*)</File_Name>"); I am trying to parse this string. ...
6
by: | last post by:
Hi all, Sorry for the lengthy post but as I learned I should post concise-and-complete code. So the code belows shows that the execution of ValidateAddress consumes a lot of time. In the test...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.