C# - Regular Expression To Validate Time Format

Jul 15, 2011

I need to validate user input in some fields, where these are defining how to show time in some views.

Requirements: Time format must be expressed in Microsoft .NET way (check this MSDN Library article if you want to learn more about framework's date and time formatting: [URL]. Keep in mind I'm looking to validate the format instead of an actual time string.

For example, user may input:
HH:mm
hh:mm
ss
hh:ss
mm:ss
... and so on.

In fact, it should validate from the shortest to longest time format available. Another point is I need to do it in client-side using JavaScript. In other words, any given regular expression by you should work in browsers JavaScript regular expressions' engine. I can't use ASP.NET validation engine, or any other. Because of project's requirements, I need to avoid that.

View 2 Replies


ADVERTISEMENT

Make A Regular Expression Format To Validate Phone Number?

Apr 15, 2012

i try to make a regular expression format to validate phone number at this format: (555) 555-5555 Dim IsPhoneValid As New System.Text.RegularExpressions.Regex("^/([0-9]{3}/)*[0-9]{3}*[0-9]{4}$")

View 3 Replies

.NET Regular Expression For Time 24 Hr Format?

Sep 1, 2009

have a regular expression in .NET, which will allow only 24 hr time format in the textbox.

View 6 Replies

Build A Regular Expression To Validate Code

Mar 20, 2011

i need to build a regular expression to validate an code. The code has 10 charaters

- the First charaters can only one the following B,F,E,S,M,P,Z

- From Second to Seventh are alfanumeric (0-9 and A-Z)

- the Eighth is the letter U

- the ninth is a number (0-9)

-the tenth is alfanumeric (0-9 and A-Z)

View 7 Replies

Regex - ASP Regular Expression For UK Telephone Format?

Sep 23, 2009

I want regular expression validator for my telephone field in VB.net. Telephone format should be (+)xx-(0)xxxx-xxxxxx ext xxxx (Optional) example my number would appear as 44-7966-591739 Screen would be formatted to show +44-(0)7966-591739 ext?

View 3 Replies

C# - Regular Expression To Define Format Of Backup Filenames

Oct 1, 2009

In the application I am currently working on, I have an option to create automatic backups of a certain file on the hard disk. What I would like to do is offer the user the possibility to configure the name of the file and its extension.

For example, the backup filename could be something like : "backup_month_year_username.bak". I had the idea to save the format in the form of a regular expression. For the example above, the regexp would look like :

"^backup_(?<Month>d{2})_(?<Year>d{2})_(?<Username>w).(?<extension>bak)$"

I thought about using regex because I will also have to browse through the directory of backuped files to delete those older than a certain date. The main trouble I have now is how to create a filename using the regex. In a way I should replace the tags with the information. I could do that using regex.replace and another regex, but I feel it's a big weird doing that and it might be a better way.

[Edit] Maybe I wasn't really clear in the first go, but the idea is of course that the user (in this case an admin that will know regex syntax) will have the possibility to modify the form of the filename, that's all the idea behind it[/Edit]

View 5 Replies

Get A Regular Expression That Can Validate That A String Is An Alphanumeric Comma Delimited String?

Jun 23, 2011

I need a regular expression that can validate that a string is an alphanumeric comma delimited string.

Examples:

123, 4A67, GGG, 767 would be valid.
12333, 78787&*, GH778 would be invalid
fghkjhfdg8797< would be invalid

This is what I have so far, but isn't quite right: ^(?=.*[a-zA-Z0-9][,]).*$

View 3 Replies

Regular Expression To Match Dates In Dd/mm/yy Format And Check For Valid Values

Jun 9, 2010

Does anyone have a regurlar expression available which only accepts dates in the format dd/mm/yy but also has strict checking to make sure that the date is valid, including leap year support?

I am coding in vb.net and am struggling to work this one out.

View 8 Replies

Setting Masked Textbox To Validate Time In 24hr Format

Jul 9, 2009

In Visual studio 2005 using VB, I've just started using a masked textbox to input time in the 24hr format.In the Input dialog box , I've set the mask to : Time(European/Military) and checked the : Use validating Type box.[code]Problem: The user can enter numbers which do not match the time format.Example:25:75 or 23:66 , etcI would just like to restrict user input to the numbers required for the 24hr format only.Also, if anyone can provide me with a link to some working examples of masked textboxes.

View 6 Replies

Regular Expression In .Net?

Oct 21, 2011

Regular Expression to count per words and characters in VB.Net. Here's my codes.

[Code]...

View 4 Replies

Correctness Of A Regular Expression

Oct 7, 2011

I'm trying to create a regex which will match either one of the following [code] This regex is supposed to return all and any form of the function that is used.If match string were - FVAL(A,"B")+5 then match group should be FVAL(A,"B")

View 1 Replies

.net - Regular Expression Works In VB But Not C#

May 19, 2009

I have the following regular expression for validating a file name:

^(([a-zA-Z]:|))?(((.)|(..)|(. %5D">^/:*?"|<>. |([^/:*?"|<>][^/:*?"|<>. ]))?))). %5D">^/:*?"|<>. |([^/:*?"|<>]*[^/:*?"|<>. ]))?$

I can get it to work in VB.NET but not C#. I can't figure out why it works in one but not the other.

[Code]...

As far as I can tell the patterns are identical in both languages with escaping. When I run the VB code I get a match. When I run the C# code I get nothing.

View 1 Replies

C# - How Optimise The Regular Expression

Oct 14, 2010

I have just coded the below regular expression. I have a mini rich text editor on a web page (very similar to the one I am using to post this question) and I want to make use of a double asterisk to indicate which words/phrases should be wrapped in a strong tag. The aim is to allow the user to add pre-defined HTML elements without actually having to submit HTML.
[code...]

Maybe I am over-optimising this, but I want to know if this can be made more efficient?

View 1 Replies

Create A Regular Expression?

Feb 12, 2009

It is a little like a search and replace, I want to replace any string that contains any substring in parentheses with the same string but the words in parentheses colored RED: Eg

Take this text in TextBox1:

"The Prime Minister (that idiot from Scotland) made a speech today"

and convert to this text in RichTextBox1:

"The Prime Minister (that idiot from Scotland) made a speech today"

View 1 Replies

Regular Expression - Parses Out Value

May 6, 2012

I had a regular expression which parses out value.

[Code]...

View 7 Replies

Regular Expression To Locate The Url In VB?

Oct 6, 2011

I am trying to use regular expression for extracting data from web page. but everytime i change the URL i need to change my regular expression for URL.

View 3 Replies

Regular Expression To Parse Xml In .net?

Mar 24, 2010

I have the following function that I am using to remove the characters �4 and nulls from my xmlString but I can't find what do I need to change to avoid removing the from my ending tags. This is what I get when I run this function

<ARR>20080625<ARR><DEP>20110606<DEP><PCIID>626783<PCIID><NOPAX>1<NOPAX><TG><TG><HASPREV>FALSE<HASPREV><HASSUCC>FALSE<HASSUCC>

find out what do I need to change in my expression to keep the ending tag as </tag>

[Code]...

View 1 Replies

Regular Expression Validator In Vb?

May 17, 2011

I have a textbox which takes as input the email address. Do you have regular expression validator in vb.net so that I can check if '@' is present or not in the string

View 2 Replies

Regular Expression With Filename?

Feb 1, 2012

I have a string (can be anything) and somewhere in the middle of the string there's a filename with the extension 'txt'. The filename can basically be anything, and any filename is correct, but with a certain exception.

If the filename ends with .part<number>.txt, the <number> can only be one of the following, 1, 01, 001, 0001.

Every other <number> is incorrect.

Match
.part1.txt
.Part001.txt

[Code].....

View 2 Replies

.net - Extract A Particular Value From An INI File Using A Regular Expression?

Dec 22, 2009

I want to extract a URL value from an INI File as such:

[DEFAULT]
BASEURL=http://www.stackoverflow.com/
[InternetShortcut]
URL=http://www.stackoverflow.com/

So I can get the URL value as the only Match from the Regular expression - but I don't understand enough about them (yet) to do this. I have seen RegEx examples that will parse any INI file and get the Name, Value Pairs I just want to get the URL value only from a file no matter what else it contains. My aim is to have something like this:

Dim _pattern As New Text.RegularExpressions.Regex("RegEx")
Dim _url As String = _pattern.Match(iniContentString).Value

It seems simple but I cannot seem to create a specific case RegEx where I want everything from "URL=" to the vbCrLf at the End to be my "Match". I have refered to Regular-Expressions.info which has been a help before but still cannot get this simple example to work.

View 1 Replies

Building A Dynamic Regular Expression?

Jun 12, 2009

I'm attempting to build a function that will return a regex that is dynamically created.The regex to create will be a range check between two numbers. So far I've got something similar to this (not finished as yet).Is this approach valid, or is there an easier way that I'm overlooking?

Public Shared Function Range(ByVal Minimum As Integer, ByVal Maximum As Integer) As String
Return "^([" & Minimum.ToString.PadLeft(2, "0") & "]" & Microsoft.VisualBasic.StrDup(Minimum.ToString.Length, "[0-9]") & "|2[0-4][0-9]|25[0-5])$"

[code]......

View 2 Replies

C# - Regular Expression For Domain Names

Apr 17, 2012

I am trying to validate a csv file of domain names (eg. @google.com, @xyz.co.uk, @xyz.edu etc.) I am using the following Regular Expression:
Regex(@"@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}$", RegexOptions.Compiled);
Is there scope for improvement on the above?

View 1 Replies

C# - Regular Expression For Valid Domains

Apr 17, 2012

Regex(@"@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}$", RegexOptions.Compiled);
Using the above, I want to pass only values like @gmail.com, @xyz.edu, @co.uk etc...
But I find that the values like abc@gmail.com (valid email ids) also pass through.

View 2 Replies

DateTimePicker - Invalid Regular Expression

Nov 11, 2009

I am using the below Regular Expression which works fine in case of date validation. But if I select the date from the DatePicket even then it throws alert:Enter valid date. How can I modify the regular expression so as to be compatible with DatePicker.

Set RegularExpressionObject = New RegExp
With RegularExpressionObject
.Pattern = "^(((0?[1-9]|[12]d|3[01]).-/.-/?d{2}))|((0?[1-9]|[12]d|30).-/.-/?d{2}))|((0?[1-9]|1d|2[0-8])[.-/]0?2.-/?d{2}))|(29[.-/]0?2.-/?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))$"
.IgnoreCase = True
.Global = True
End With
[Code] .....

View 2 Replies

IDE :: Regular Expression Got Parsing The Html

Sep 15, 2006

get generic regular expression for my html file ....????? My html is....

[Code]...

View 2 Replies

Make The Regular Expression For Validations?

Jan 10, 2012

i'm trying to make the regular expression for validations, but I can't manage to get a control of the result I want.

I wanna input in a textbox the following :

(029)-234-2342342

Or what is the same, the ( ), 3 numbers inside, a "-", 3 numbers, another "-" and 7 numbers.

How can I manage it??

View 3 Replies

Regex :: How To Write Regular Expression

Sep 14, 2010

My coworker needs me to write him a regular expression for his vb.net app.I do not know vb and he does not know regex.The regex he needs is:/.*web id: ?(d+).*/iBasically he needs to search a string for something like "web id: 345" or "web id:2534" and retrieve the ID.He took what I gave him above and was able to put this together:

Dim strPattern As String = ".*web id: ?(d+).*"
Dim strReplacement$ = "$1"
GetWebId$ = Regex.Replace(LCase$(strNote$), strPattern$, strReplacement$)

[code].....

View 2 Replies

Regular Expression - Match A String

Jul 2, 2009

I want to match a string for example "yes" but where it is not in brackets so that the following would be matched: yes (bla yes bla) bla yes

View 7 Replies

Regular Expression - Match Domain In URI

Jan 8, 2011

How can I match the domain part only of a URI with regular expressions? I see lots of examples but the mutch the subdomain too. What I am looking to do is to capture only the domain. So, for example [URL] should match only google. As a secondary question, I am looking to implement this on a VB.NET program. Would there be some other way to do it without regular expressions?

View 2 Replies

Regular Expression : Match A String That Contains A,B,C,D,E And F?

Jul 2, 2009

I want a regular expression for the following issue:I want to match a string that contains A,B,C,D,E and F. string length should be 0 to 6. and not character should be repeat in the string.Example: ABCDEF, ACDEFB, EFBCDA, etc. but not ABBCDES/W Engineer

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved