.net - C# - Faster: String.Contains() Or Regex.isMatch()?
Jul 6, 2010
Possible Duplicate: Regex.IsMatch vs string.Contains Which is faster, preferable and why?What the difference in mechanisms between two?I need to search for some values from UserAgent, most of values can be used without wildcards (e.g. if I want to catch cellular phones I search for iPhone instead of *iPhone* wildcards).
View 1 Replies
Similar Messages:
Apr 28, 2010
I would like to make sure a time with correct format (HH:mm)
this is my code
bool timeCheck = true;
string[] time = ArrivalTIME.Text.Split(':');
if (time.Length > 2)
{
if (time[0].ToString()< 0 || time[0].ToString() > 23)
timeCheck = false;
if (time[1].ToString() < 0 || time[1].ToString() > 59)
timeCheck = false;
}
else
timeCheck = false;
but this code will cause some problem ArrivalTime.Text = "aa:bb" caused syntax error..
just wondering would this check done by Regex ?
View 4 Replies
Apr 4, 2011
i have a problem in string manipulation
here is the code
string str = "LDAP://company.com/OU=MyOU1 Control,DC=MyCompany,DC=com";
Regex regex = new Regex("OU=\w+");
var result = regex.Matches(str);
var strList = new List<string>();
foreach (var item in result)
{
strList.Add(item.ToString().Remove(0,3));
}
Console.WriteLine(string.Join("/",strList));
the result i am getting is "MyOU1" instead of getting "MyOU1 Control"
View 2 Replies
Jan 6, 2010
I need to find a regex that tests that an input string contains exactly 10 numeric characters, while still allowing other characters in the string.
I'll be stripping all of the non-numeric characters in post processing, but I need the regex for client-side validation.
For example, these should all match:
1234567890
12-456879x54
321225 -1234AAAA
xx1234567890
But these should not:
123456789 (not enough digits)
12345678901 (too many digits)
View 3 Replies
Jun 16, 2010
I am getting taggings like the following in a string
<color> vocation </color>
<color> elation </color>
<color> sage </color>
you can notice that each tagging differs only in the wordings
vocation
elation
sage
But i want to write a code some thing like this
Regex.Replace(userAx, "<color> vocation </color>",
"<color> </color>"
so that the resulting output does not contain words at the centre.In the above code instead of giving the word vocation exclusively, i have to mention some pattern, so that it will replace all the words instead of doing it for first sentence only.How to modify my code?
View 6 Replies
Mar 11, 2011
I am trying to get all the words in a string using a regular expression.When I use this expression in javascript, it works, but when I try it in the .Net code I get the whole string.this is my code.Is my regular expression wrong or am I using the wrong method?
Code:
Dim myRegex As New Regex("/([a-zA-Z]){1,1}([a-z])+/g")
Dim str() As String = myRegex.Split(text)
View 3 Replies
Oct 24, 2010
I am trying to check if a string ends in "@something" and extract "something" from it if it does. For example, I am trying to do something like this:
string temp = "//something//img/@src"
if (temp ends with @xxx)
{
string extracted = (get "src");
...
}
else
{
}
How can I accomplish this?
View 3 Replies
Oct 6, 2010
I am using the following code for extracting a number from string 'sentence'.
Regex.Split(sentence, @"D+");
For Ex: This is test , message contains 192837 and the message ends here.
This output would be 192837.
Now, Let say: sentence is: This is test, 2736 message contains 293743 and message ends here.
This output would be 2736293743.
But, I want only 2736. i.e The first number in a string omit rest all others.
How to deal with this?
View 3 Replies
Jan 11, 2011
In my table below string are present which I have to replace *@*$*86$*$ with blank, how can I do? Here bold can be 0-99, in any row.
xOsyH *@*$*86$*$
M. V. *@*$*81$*$ .
View 8 Replies
Oct 25, 2010
What is the regular expression for a RegularExpressionValidator so it fires if the string in the validated control contains a r is longer then 250 chars?
View 1 Replies
Feb 4, 2011
I have a table Books with columns BookID, BookSummary, BookAuthor.
What I have stupidly done was to add a link to another url at the end of the BookSummary. Assuming the text is something like this:
This is a book about a love story in World War 2 in Europe. The book is written by Elliot James.
I have added
<a href='http=://XXXXXX'>Buy Book</a> at the end of the text making the final content of BookSummary to be like:
This is a book about a love story in World War 2 in Europe. The book is written by Elliot James.
<a href='http=://XXXXXX'>Buy Book</a>
I now need to write a code (via regex?) to read through each BookSummary, find the <a href='http://XXXXX'>Buy Book</a> and delete it. But the problem is the content in XXX could be anything and I cannot use typical string functions. Can anyone guide me to
achieve this using Regex?
View 7 Replies
May 1, 2010
What's the regular expression to check if a string starts with "mailto" or "ftp" or "joe" or...
Now I am using C# and code like this in a big if with many ors:
String.StartsWith("mailto:")
String.StartsWith("ftp")
It looks like a regex would be better for this. Or is there a C# way I am missing here?
View 5 Replies
Mar 1, 2011
I want to write a Regex in DataAnnotations that can unmatch a input string containing not paired double quote " ie. check if zero or a paired double quote allowed in a input string.
matched case:
abcde
"abcde"
abc"d"e
unmatched case:
"abc"de"
"abcde
abc"de
abcde"
MY EXISTING CODE FYR:
using System.ComponentModel.DataAnnotations;
using Microsoft.Web.DynamicData;
namespace EDMModel
{
[MetadataType(typeof(DETAIL_MetaData)), ScaffoldTable(true)]
public partial class DETAIL{}
public class DETAIL_MetaData
{
[Required, RegularExpression(@"[^~`!@#%&()={}|:;'<>,./+?*^$]*", ErrorMessage = "Unsupported Character detected"), StringLength(20), Display(Order = 21)]
public object NAME1 { get; set; }
View 5 Replies
Mar 2, 2010
I have a problem trying to create an array of 3 dateparts.. since "" is a special character..
[Code]....
View 4 Replies
Feb 19, 2010
I'm having a little trouble with using regex in linq. I want to be able to perform a search on values in my database. The goal is to insert a value into the regex and then use that to search a column in a table in my database for that term. I want it to work so that it gets all exact matches and also returns matches in which the search term is a substring of the term in the column.
I was trying to follow this tutorial on msdn, but it doesn't quite fit perfectly with my problem:
[URL]
Code:
[code]....
View 11 Replies
Jun 18, 2010
I need to replace <span> entries in a string to legacy html code because it's going to be used in a report for Crystal Reports. <b> works with Crystal, but the<span>'s do not.
Here's the string which I'm trying to replace: <span style="font-weight: bold">%THIS CAN BE ANY TEXT%</span>. I want to replace it to
<b>%THIS CAN BE ANY TEXT%</b>.
[Code]....
View 5 Replies
Jun 28, 2010
Lets say its just for a simple website with pages such as Home, About, Contacts, etc..
View 1 Replies
Nov 16, 2010
I am investing some time in learning ASP.NET and more specifically ASP.NET MVC and I am curious how it stacks up to the competition. I really like what I am seeing so far with the framework, and I think the icing on the cake would be if it shows rock solid speed like I have seen with some ASP.NET form sites.
Has anyone done or seen fair comparisons or benchmarks? I would be interested to see how ASP.NET MVC stacks up against other solutions such as PHP MVC too.
View 2 Replies
Jul 20, 2010
How to make sql query run faster . Below is my query:
SELECT [FieldValue2] = case isdate(FieldValue2) When '1' then
case isdate(FieldValue4) When '0' then
dbo.GetCountagingDay(FieldValue2, getdate(), '') -1
else
'0'
end
else
'0'
end
FROM test
View 6 Replies
Jun 15, 2010
I have a gridview which displays data for all employees and their images (stored in database).
The images take more time to render completely when i click sort or paging or reload.
I'm using httphandler to display image as stream.
Is there a way i can speed up this image loading?
View 1 Replies
Oct 17, 2010
i want to know whether views or stored procedures are faster. i am developing application in asp.net with sql server. Which one should i use for good performance of asp.net application.
View 2 Replies
Dec 11, 2010
i find a lot of websites that have some parts in the page that uses ajax much more faster than i used to see ajax requests
like changing views using tabs when i click a tab it changes content very fast than i used to in my web applications using Asp.Net and Ajax Control Toolkit
and also a very quick paging in repeaters or grids than i ever developed in my web apps
like this website [URL] i need to know which technology used to achieve this this website is developed using .net
so
but i need to know is this needs another technology to learn (from where can i learn it)
or is it just asp.net + ajax or whth other technology
is it MVC
also i want to know if MVC is better than asp.net + ajax in concern with performance
View 4 Replies
Mar 30, 2011
Are you experienced with both ASP.NET and WPF coding? If so, I'll be grateful if you'll share your experience, We are estimating a 100-screen WPF project. Our estimation methodology involves characterizing the complexity of each screen. We then apply a standard number for the development time, based on the complexity and the technology. The standard number is based on the developer being good, not a super-star.
For example, here's a screen:
[Code]....
View 3 Replies
Mar 21, 2011
How to load asp.net webpages faster using .htaccess..
what was the coding for .htaccess so that the webpages loads faster ..i have hosted my site on .ixwebhosting.
View 1 Replies
Mar 1, 2011
Why does ASP.NET pages render time on Chrome and FF is ~ 3X the render time on IE ??This problem only persist on my local machine, but when published to the real server the complete opposite happens (expected, as FF and Chrome outperform IE).
I tried Windows 7 x64 and Windows XP x86 with FF 3.6, Chrome 9, and IE 8.
Is there any thing I can do on IIS or in the web config to fix this behavior ?
EDIT: In response to the responses an domments:
I don't have these issues when running PHP + apache, or JSP
I noticed this behavior when doing a debugging session in VS or after deploying on IIS
Modifying the hosts file did improve Chrome and FF response time indeed, but still slower than IE !
View 2 Replies