C# - Regex Pattern / Looking For The X_X Numeric Patterns?
Dec 23, 2010
I will have the following possible strings:
12_3
or
12_3+14_1+16_3-400_2
The numbers could be different, but what I'm looking for are the X_X numeric patterns. However, I need to do a replace that will search for 2_3 and NOT return the 12_3 as a valid match.
The +/-'s are arthemtic symbols, and can be any valid value. They also ARENT required (in the example of the first) .. so, I might want to check a string that just has 12_3, and if I pass in 2_3, it would NOT return a match. Only if I passed in 12_3.
This is for a C# script.
View 2 Replies
Similar Messages:
Mar 7, 2011
YARPQ - Yet Another Regex Pattern Question:
What I am trying to figure out is how to use a custom delimiter, single character or set of characters, to wrap a block of text inside a larger body of text and then pull that text out via regex. I have successfully done this with a single instance of wrapped text. If I have multiple instances, it blows up. Here is an example.
This would be my text block with the internally wrapped text:
[Code]....
When my current regex runs on this block, the greedy nature gives me a match starting with my first wrapped block delimeter and ending with my second wrapped block end delimeter. So my regex of @"#Delim(.*)#EndDelim" doesn't work in this instance. I am trying to figure out how to exclude the #EndDelim from my grouping. Simply using ([^#EndDelim]*) doesn't work as it tells regex to ignore the individual characters inside the brackets and not the actual word so this breaks if I have any of those characters inside my wrapped block of text.
I am probably making this harder than it needs to be. Does anyone know of a good solution or how to ignore entire words in regex?
View 3 Replies
Dec 14, 2010
I want regex pattern for phone number as follow.
(111)-111-1111
area code should be entered in paranetheses is mandatory after area code there should be hypen and only three digit should be allowed to enter that is mandatory after 3 digit again hypen should be there that is mandatory and then 4 digit should be enter that is mandatory.
View 4 Replies
Sep 7, 2010
asp.net 4.0
I wonder what the Regex pattern for session id is?
View 1 Replies
Jan 27, 2011
I need regex patter for following code.Text with length either 9 0r 16 should only be allowed.
if (txtId.Text.Length != 16 && txtId.Text.Length != 9)
{
//lblError.Text = "Please enter a valid ID";[code]....
View 5 Replies
Jan 20, 2010
I'm trying to build an asp.net page using c# that will query a column in an Oracle database that has 20,000 rows. I want to display all rows that match this regular expression pattern "[]$".(should only have about 5 rows that match this pattern) The version of Oracle we use does not support regex so I need to find a way to do this in c# but I'm not sure how do that.
View 2 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
Jan 10, 2011
1.what is the difference between design patterns vs architectural patterns ?
2. In which situations They are preffered?
View 2 Replies
Apr 18, 2010
i have set the type of a column in a table numeric(6,2) but when i insert a value above 9999,99 i get the error
"Arithmetic overflow error converting numeric to data type numeric."
Do you know whats wrong??
ofc thats all through visual studio for an asp site thats why im posting here
View 4 Replies
Feb 15, 2010
First of all im new to asp.net and am in the process of learning it.
Heres my problem, i am receiving this error when submitting the form: "Arithmetic overflow error converting numeric to data type numeric"
And it halts at command.ExecuteNonQuery();
Input form:
[Code]....
Code Behind:
[Code]....
Stored Procedure:
[Code]....
View 11 Replies
Oct 13, 2010
We have an ASP.NET MVC site that uses Entity Framework abstractions with Repository and UnitOfWork patterns. What I'm wondering is how others have implemented navigation of complex object graphs with these patterns. Let me give an example from one of our controllers:
[code]....
It's a registration process and pretty much everything hangs off the POCO class Person. In this case we're caching the person through the registration process. I've now started implementing the latter part of the registration process which requires access to data deeper in the object graph. Specifically DPA data which hangs off Legal inside Country.
The code above is just mapping out the model information into a simpler format for the ViewModel. My question is do you consider this fairly deep navigation of the graph good practice or would you abstract out the retrieval of the objects further down the graph into repositories?
View 2 Replies
Feb 23, 2010
Does anyone have a working pattern for converting a GET-POST-GET pattern to asny?
I'm encountering the following issues:
1. You cannot mix Sync and Async action methods SubmitForm(), SubmitFormAsync(bool? confirm), SubmitFormCompleted() ... (because the resolver gets all confused ... it doesn't use the HTTP verb to decide who to target. BTW: I think that's poor design, or a bug)
2. Renaming the get method name to something else eg: SubmitFormConfirmation(), SubmitFormAsync(bool? confirm), SubmitFormCompleted() would be very awkward if it works ... because you have to doctor the <form markup to specify an action name.
3. You cannot give them all async names SubmitFormAsync(), SubmitFormAsync(bool? confirm), submitFormCompleted(), because the call just keeps malfunctioning. It sometime even behaves as if you are requesting a delete of something.
Can someone give an insight from an actually working sample.
View 5 Replies
Aug 21, 2010
Now that the next version of ASP.NET MVC is being prototyped and previewed (ASP.NET MVC 3 Preview 1 came out a couple of weeks ago), I wonder if we should call the attention of the Core Dev team (S Hanselman, Phil Haack and all) to this "feature."there a easy/non tacky way of associating subdomains → areas?Something like:
[URL]Also, whats the best accepted design pattern in implementing PRG pattern in ASP.NET MVC? I guess it should also get some official loving in MVC 3.
View 2 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
Aug 9, 2010
I've just encountered an interesting problem in a standard BoundField in a GridView. The field is for EmployeeCode, which is purely numeric, but stored in a character column in the database. The DataFormatString="{0:00000}" attribute on the BoundField doesn't work, as I assume that format is only for numeric values.
To work around this, I had to use a TemplateField, and bind the text value using the attribute Text='<%# PadNumericString(Eval("EmployeeCode").ToString(), 5) %>'. Is there no simpler way of doing this?
View 1 Replies
Jun 24, 2010
I need to implement a wizardy, dynamic UI that uses complex validation of the style:
If A = 1, show controls B, C, D. B is required, C is not, and D is not required must be less than 30 if it is populated.
If A = 2, show controls B, D, E. B is not required, D is required but has no limits, and E is not required.
If B is not null, show controls B, D, E. B is not required, D is required but has no limits, and E is not required.
Historically, I have made my presentation layer as "dumb" as possible in that it is only responsible for capturing user input and binding it to the appropriate domain model. The domain model, in turn, contains the logic needed to validate it's state and that of any child objects, and then communicates any invalid state to the presentation layer via notifications. As such, this requirement for a highly "intelligent" UI represents a departure for me.
I think I have no choice but to construct 2 very similar class hierarchies:
one that will capture presentation business rules (i.e. what fields are visible) and control what renders in the View
one that will capture domain business rules (when field A = X, then field B should be not null and in the range of n to m) to disallow objects with an invalid state from being persisted
Sill I have far more questions than answers on my strategy moving forward. Is there a set of design patterns I can draw on to build such a dynamic UI? I do have the option of using ASP.NET MVC or WebForms, so whichever approach will produce cleaner, testable code is preferred.
View 1 Replies
Feb 18, 2010
i created an intranet based website(information Portal)...i would like to know the pages each user visits and i want track there behavior...what tools should i include..
View 2 Replies
Apr 27, 2010
what are design patterns and UML diagrams with best examples. How we should use in real time scenarios. Recurring iam facing these type of questions in project round.
View 5 Replies
Jul 9, 2010
Does anybody knows good, short and slim tutorials (not here ), which describe actual/modern web-application architectures / patterns (especially for ASP.NET based (classic and MVC) applications (maybe also with embedded Silverlight components) ? How would you you design today an ASP.NET application which uses different datasources (databases, services,...) ? Background: I has been away a couple of years writing web applications, and I want to start now again. So at the moment I am a little bit unsure, how to take off and find the right starting point.
View 3 Replies
May 17, 2010
I'm trying to build a small, web application. But I want to use desing patterns in it. So I have a question: which desing patterns do you use and why in asp.net applications?
View 11 Replies
Nov 20, 2010
I want a regular expression patterns to match for the following example.
USER@DOMAIN.COMDOMAIN\USERUSER
I need only the USER to be extracted from those.
View 2 Replies
Mar 9, 2011
I thought it should be a simple straight-forward matter but after struggling with it for too much time.
What I need is to redirect all requests for my web application that match the following pattern - "^(http://[^/]+/blogs/[^/.]+)/?$" to the path of "$1/Default.aspx".
(Using English rather than Regex: [URL]
The sub-directories in "blogs" do not physically exist, instead a 3rd party product deals with the requests to randomdir/Default.aspx", but when you go to "randomdir/" you get 404 not found, which is what I'm trying to fix.
I tried to use global.asax and also HttpHandler, but I couldn't get either of them to fire up on the requests to those 404 paths.
So, in short, what should I do to redirect paths of non-existing directories?
View 2 Replies
Feb 4, 2010
Let's say you're building something simple, like a data entry/CRUD form for working on an entity called Customer. Maybe you pass the CustomerID in via Session state.I tend to write a lot of fairly boilerplate plumbing code around handling that Session variable in a particular way. The goals vary slightly but tend to be things like:
Avoid cluttering the main flow of the page with plumbing code
Handle the back button intelligently
Remove the variable from Session and persist it to ViewState ASAP
Code defensively for failure situations where the state doesn't get passed, or is lost
Do you have a best practice for handling this situation? Do you have classes in your stack that handle this perfectly every time? Do you just call the Session variables directly? Do you use encrypted QueryString and avoid Session variables in this situation entirely in order to make the back button work a little better?Lately I've been using Properties with Session variables. Here's a simple example that I just threw together, although please keep in mind that this example would not be very tolerant of the back button:
Private ReadOnly Property CustomerID() As Integer
Get
If Me.ViewState(Constants.CustomerID) Is Nothing Then[code]....
View 1 Replies
Sep 22, 2010
I'm trying to decide which of the two factory patterns I should use in my Asp.Net applications:
1 : All DAL providers derive from same abstract base class DepartmentsProvider, which defines public interface of the class ( all the necessary CRUD methods for which derived classes (providers ) provide a concrete implementation ). BLL layer instantiates correct provider by calling DepartmentsProvider.Instance:
public abstract class DepartmentsProvider
{
static private DepartmentsProvider _instance = null;
/// <summary>[code]....
In first case we implement new provider by deriving from DepartmentsProvider class, while in second case new provider is implemented by deriving from DBProviderFactory. What are pros and cons of each implementation?
View 1 Replies