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

RegularExpressions

I want get the Matchs
<li>[xxxxxxxxxxxxxxxxxxxxxxxxx</li>
begin:<li>[
end:</li>
Nov 16 '05 #1
5 1337
Unless you need resiliency in the pattern, you are better of using IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as well
as you demonstrate below.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Bill Yin" <yi********@yahoo.com.cn.discuss> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
I want get the Matchs
<li>[xxxxxxxxxxxxxxxxxxxxxxxxx</li>
begin:<li>[
end:</li>

Nov 16 '05 #2
Which faster using indexOf or RegularExpressions?
"Justin Rogers" <Ju****@games4dotnet.com> 写入邮件
news:Ou**************@tk2msftngp13.phx.gbl...
Unless you need resiliency in the pattern, you are better of using IndexOf. By resiliency, I mean the ability to handle tags that aren't formed as well as you demonstrate below.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Bill Yin" <yi********@yahoo.com.cn.discuss> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
I want get the Matchs
<li>[xxxxxxxxxxxxxxxxxxxxxxxxx</li>
begin:<li>[
end:</li>


Nov 16 '05 #3
IndexOf is going to be massively faster in most cases in searching for
start and end tags of fixed form like you show below. Actually I take
that back, you are actually going to need to use something that does
a substring match:

http://weblogs.asp.net/justin_rogers.../14/89545.aspx

The above algorithm should get you going.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Bill Yin" <yi********@yahoo.com.cn.discuss> wrote in message
news:O2****************@TK2MSFTNGP11.phx.gbl...
Which faster using indexOf or RegularExpressions?
"Justin Rogers" <Ju****@games4dotnet.com> 写入邮件
news:Ou**************@tk2msftngp13.phx.gbl...
Unless you need resiliency in the pattern, you are better of using

IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as

well
as you demonstrate below.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Bill Yin" <yi********@yahoo.com.cn.discuss> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
I want get the Matchs
<li>[xxxxxxxxxxxxxxxxxxxxxxxxx</li>
begin:<li>[
end:</li>



Nov 16 '05 #4
IndexOf should be, given that Regexes have the tradeoff of more advanced functionality. Try profiling it - I tried compuware devpartner community edition profiler - free, integrates into VS.NET and I must say the support is quite good aswell. Not to mention works dead well and highlights the slowest line of code in red - something I find dead useful!
"Bill Yin" wrote:
Which faster using indexOf or RegularExpressions?
"Justin Rogers" <Ju****@games4dotnet.com> 脨麓脠毛脫脢录镁
news:Ou**************@tk2msftngp13.phx.gbl...
Unless you need resiliency in the pattern, you are better of using

IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as

well
as you demonstrate below.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Bill Yin" <yi********@yahoo.com.cn.discuss> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
I want get the Matchs
<li>[xxxxxxxxxxxxxxxxxxxxxxxxx</li>
begin:<li>[
end:</li>



Nov 16 '05 #5
Regex performance depends on the complexity of the search pattern. If you
search for a fixed pattern, to compare it's speed with IndexOf, Regex'es are
faster (than IndexOf) on long strings. (personal experience)

Niki

"Bill Yin" <yi********@yahoo.com.cn.discuss> wrote in
news:O2****************@TK2MSFTNGP11.phx.gbl...
Which faster using indexOf or RegularExpressions?
"Justin Rogers" <Ju****@games4dotnet.com> 写入邮件
news:Ou**************@tk2msftngp13.phx.gbl...
Unless you need resiliency in the pattern, you are better of using

IndexOf.
By resiliency, I mean the ability to handle tags that aren't formed as

well
as you demonstrate below.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Bill Yin" <yi********@yahoo.com.cn.discuss> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
I want get the Matchs
<li>[xxxxxxxxxxxxxxxxxxxxxxxxx</li>
begin:<li>[
end:</li>



Nov 16 '05 #6

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

Similar topics

4
by: Nico Grubert | last post by:
Hello, I want to remove all html tags from a string "content" except <a ....>xxx</a>. My script reads like this: ### import re content = re.sub('<((|\n)*)>', '', content)
1
by: Mosas | last post by:
Dear All In Perl when we are checking some conditions using regular expression we can ignore the case sensitive of a string using the following regular expression /(^)|/|(\.\.)/i. But If I try...
2
by: Juan | last post by:
Hi, I磎 using System.Text.RegularExpressions, I want to find any acurrence of the char & or % or | Ehat is the correct sintax for the Match method? This is what I磎 usinf but is not working:...
2
by: Doug | last post by:
I'm a little confused by this functionality. It doesn't seem to be behaving like it should. I am using the following regular expression to validate email addresses:...
3
by: Gon鏰lo Bol閛 | last post by:
Can i validate a TextBox with a regular expression without using RegularExpressionValidator? Can i use a function to do this? I wan't to throw an error different from the way...
8
by: Richard Lionheart | last post by:
Hi All, I tried using RegEx, but the compiler barfed with "The type of namespace 'RegEx' could not be found. Prior to this, I had the same problem with MatchCollection, but discovered it's...
0
by: Neo The One | last post by:
I find some of the Regex classes are quite helpful for my learning. For example: System.Web.RegularExpressions.SimpleDirectiveRege...
3
by: Curious | last post by:
I have another question about Regular Expression. If I use: if (temp.Contains("Ending") == true) { temp = System.Text.RegularExpressions.Regex.Replace(temp, "Ending", "Beginning"); } It...
1
by: alexvorn2 | last post by:
This is the code for finding a text that is between "<" and ">": Dim fileContents As String = My.Computer.FileSystem.ReadAllText("c:/test.txt") Dim RegularExpression As New...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.