C# - Shall This Regex Do What Expect From It That Is Matching Against "A1:B10,C3,D4:E1000"

Mar 9, 2011

I'm currently writing a library where I wish to allow the user to be able to specify spreadsheet cell(s) under four possible alternatives:

A single cell: "A1";
Multiple contiguous cells: "A1:B10"
Multiple separate cells: "A1,B6,I60,AA2"
A mix of 2 and 3: "B2:B12,C13:C18,D4,E11000"

Then, to validate whether the input respects these formats, I intended to use a regular expression to match against. I have consulted this article on Wikipedia:

Regular Expression (Wikipedia)

And I also found this related SO question:regex matching alpha character followed by 4 alphanumerics.Based on the information provided within the above-linked articles, I would try with this Regex:

Default Readonly Property Cells(ByVal cellsAddresses As String) As ReadOnlyDictionary(Of String, ICell)
Get
Dim validAddresses As Regex = New Regex("A-Za-z0-9:,A-Za-z0-9")

[code]....

1. Is my regular expression correct? If not, please help me understand what expression I could use.

2. What exception is more likely to be the more meaningful between a FormatException and an InvalidExpressionException? I hesitate here, since it is related to the format under which the property expect the cells to be input, aside, I'm using an (regular) expression to match against.

View 5 Replies


ADVERTISEMENT

Regex Matching And Results?

Apr 16, 2009

how would i get this USERNAME, USERID from this string:

Code:
<a href="javascript:attackWindow('USERNAME','USERID','50','RANDSTRING', 'RANDSTRING2')">

Adding the USERNAME to listbox, and then USERID into an array separated by a space.

View 2 Replies

Regex Matching Wrong ID

Mar 30, 2011

How ever it is returning wrong results. Any one spot the mistake. Needs to return the username / ID from every online user from [code]...

View 3 Replies

VS 2008 Regex Matching And Results?

Apr 17, 2009

i'm really new at the VB language only been doing for around 2 weeks.I hoping someone can help me with this, how would i get this USERNAME, USERID from a string

Adding the USERNAME to listbox, and then USERID into an array separated by a space. - I no how to do this part just the regex above remember i've only been doing for two weeks so i'm not very knowledged at this.

View 11 Replies

Matching A Specific File Name Structure With Regex?

Jun 21, 2011

Regex in VB2008.I have a file system directory that my code is watching. When a file is placed in that directory my code kicks off a processing application. Based on the filename structure, the code will perform different processes. So I need to match the filename structure specficially to get the correct processes to run on that file.My file name structure is: IK2YYYYMMDD_VV.e;where YYYYMMDD is well, the year, month and day. And VV is a verison number from 00-99 If the new file saved in the directory match this structure then I want a TRUE returned. From a filewatcher I get the filename as an "e.Name" (FileSystemEventArgs) variable. My current code to see if it matches the baseline structure is;

Dim IKPred2Match as New Regex ("^IK2.*\.e$") Dim ValidIKPred2Match as MatchCollection = IKPred2Match.Matches(e.Name)I've tried many different regex match patterns, and just can't seem to find the magic one.

View 2 Replies

VS 2010 Simple Regex Pattern Matching?

Jul 1, 2011

I need an extremely simple regex pattern that matches anything within square brackets [].

Example:

This is a [test] text with [some] [examples].Required results: [test], [some], [examples].I don't want to get rid of the brackets, they should be included in the result (that should make it easier, right?)

If possible I'd like to exlude results that have whitespace in them, so things like [this string] should not be matched. If that gets too hard (probably not, but hey I can't even manage this :S) then I don't really mind, I can always check if the result contains whitespace myself.

I tried a lot of examples I could find online and ones that I could think of myself but none work. Note: I've been testing with the Visual Studio Find dialog (checking to use regular expressions obviously), maybe that's where the problem lies, because I don't really understand why some of these don't work...

Anyway, first thing I tried was simple: match the two brackets and one or more characters in between (that should be a +, right?)

View 4 Replies

Correctly Matching Ending Tag With Its Starting Tag In HTML With A RegEx

May 29, 2009

I'm using VB.Net in an ASP.Net 2.0 app to run some regular expressions that remove some unnecessary markup. One of the things that I'd like to do is remove span elements that don't have any attributes in them:[code]I'd like to remove the outer span elements. Unfortunately, my regex above gives me this as a result, since the closing span matches the first one it comes across:[code]

View 4 Replies

Regex - .NET Regular Expressions, Matching Escape Characters?

Dec 3, 2010

I want to use Regex.Replace to replace a Match with a context sensitive value. I use the MatchEvaluator for this. But to make things simpler lets say I'm matching %v I want %v to be escapable, so if I use \%v it will not match. Anything else should match.

The pattern I came up with is this: (?:[^\]|^)%v It basically matches %v if it occurs at the beginning of the string, or if it follows any character except . It doesn't capture the first part of the expression.I know this isn't the "right" way to do it. But it worked just fine until I noticed that when I use this pattern in a replace, it includes the character before %v in the replacement(duh, right?)So, if I have ThisIsAValue:%v and I do Regex.Replace, replacing with the string Value, my result will be ThisIsAValueValue instead of ThisIsAValue:ValueI've tried googling this but the fact that "escape character" is so heavy in RegEx, all the results are geared towards the USAGE of escape characters instead of picking them out with a pattern.

View 1 Replies

VS 2008 Multiline Regex Matching Doesn't Work

Sep 5, 2009

I've been working with Regex and I've run into something that doesn't make sense to me; I either misunderstood how the Multiline option works, I'm not using it right, or it really just doesn't work like it's supposed to. This is a little test I made:

[Code]...

View 18 Replies

Regex - Matching And Replacing The Contents Of Multiple Overlapping Sets Of Brackets In A String?

Jun 5, 2011

I am using vb.net to parse my own basic scripting language, sample below. I am a bit stuck trying to deal with the 2 separate types of nested brackets.

Assuming name = Sam
Assuming timeFormat = hh:mm:ss
Assuming time() is a function that takes a format string but
has a default value and returns a string.

[code]....

I could in theory change the syntax of the script completely but I would rather not. It is designed like this to enable strings without quotes because it will be included in an XML file and quotes in that context were getting messy and very prone to errors and readability issues. If this fails I could redesign using something other than quotes to mark out strings but I would rather use this method.

Preferably, unless there is some other way I am not aware of, I would like to do this using regex. I am aware that the standard regex is not really capable of this but I believe this is possible using MatchEvaluators in vb.net and some form of recursion based replacing. However I have not been able to get my head around it for the last day or so, possibly because it is hugely difficult, possibly because I am ill, or possibly because I am plain thick. I do have the following regex for parts of it.

Detecting the parentheses: (w*?)((.*?))(?=[^(+)]*((|$))
Detecting the square brackets: [[(.*?)]](?=[^[+]]*([[|$))

View 2 Replies

In Percentage, Should Expect The User To Enter 4 For 4%?

May 24, 2010

If we format a value for percent "{0:#%}" then it will become 400%, and this also applies to all the 3rd party controls I've tried. I've used custom format as a workaround for this but perhaps you guys could enlighten me on this one. If a user inputted 4 for example then did the user intended 4% or 400%? If it were me that I would expect the 4 to be 4% rather than 400%.

View 11 Replies

Expect Some Dialog Window To Appear In A Non-modal State?

Apr 19, 2009

If I type this code (VB.net 2003):

Dim myDialog As frmTestDialog
myDialog = New frmTestDialog
myDialog.Show()

you'd expect some dialog window to appear in a non-modal state. For some reason, this isn't the case with a program I am working on. Most of the dialogs use ShowDialog() to open them, and one uses Show(). The second I try to show another non-modal dialog, the dialog appears in a modal state. Another strange thing is, before I show the dialog, there is code to shift the dialog location to centre it on the main form - this isn't executed either: the dialog appears at 0,0.

My usual trend is to blame myself for errors (usually the case), then I blame the software; I have checked every single line of code (including the generated code), and it all checks out - the dialog should be non-modal. But ... it's not. I've come across other errors in VB.net 2003; is this another instance?


I'll try creating a new dialog and displaying this non-modal, and see what happens. If it works, I can just transplant the code but this shouldn't be happening, just like if I go to a shop, ask for a cola, I expect a cola not a Chinese panda; more annoying, I return the panda, ask for a cola, and they give me the panda back do loop until I give up The system does using threading, but none of that code connects to the display dialog routines all dialogs are opened with more-or-less the above code (a few have simple validation routines).

View 5 Replies

Expect The IsInterned Method To Return Null?

Feb 9, 2012

Take the below example. I would expect the IsInterned method to return null, because this string can't possibly be in the intern pool having started up the test app for the first time? I would also expect, that if I did something like string.intern("this112233StringCan'tPossiblyBeInTheInternPool!£$%") first, then this would legitimately be returned by IsInterned from the pool. I've also done the same in c# and the behaviour is the same.

Whenever I use strings in code, I tend to do something like textbox.text = string.intern("someValue") etc or if (textbox.text = "someValue") etc. Infact, whever strings are being used, I've gotten in to the habbit of using string.intern. Is this a bad habbit rather than using constants or the resources file?

[Code]...

View 19 Replies

Feature Updates Expect With Future Version

Dec 3, 2009

After right clicking on the form Context Menu give option to see 'View Code Window' which opens the the view code window and shows from the first line of code in the file, where actually it should show Event handlers related to the control on which Mouse was right clicked. right now we have to go through the line of codes to locate the event related to particular control.Also after double clicking on the control, VB inserts a default event handler to Code file which should happen only when there is no Event Handlers added for that control previously & if a previously added Event Handler present, double clicking controls should locate that procedure.[code]after dragging dataset table to the form vb assigns 'field name' concatinated with 'TextBox' to TextBox Control likewise 'field name' concatinated with 'ComboBox' for ComboBox Control where it is difficult to locate them in Controls Member list into code..Instead why don't you prefix them with 'txt' for TextBox, 'cbo' for ComboBox etc. It is then easy to find one in code. Or make the original Optional.

View 7 Replies

Passing Class ByRef Doesn't Act Like Expect It To

Dec 31, 2009

This is the code:

Public Class userDefClass
private b as integer = 1
End class
Public Class Form1
private SomeClass as new userDefClass
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) [Code]...

View 7 Replies

Stored Procedure Expect For Autonumber Field As Parameter

Mar 21, 2011

I have problem here when executing when saving data/ inserting data to db using stored procedure.[code]Waitress_ID is an autonumber field (identity set to yes). the error i get is this : Procedure or function 'WaitressDataSave_SP' expects parameter '@Waitress_ID', which was not supplied (code execution stop at the line ..da.Fill(dt) )as per i know that i don't need to include waitress_ID in my insert query because sql server automaticly assign autonumber.if i debug before the error line, i can see each variable has its content in param , except for the Waitress_ID.[code]fearness means 'looking for mistakes in the future', if only you could always remember that the future is uncertain then you would never try to predict what could be a mistake, and your fearness ends right away.

View 3 Replies

Visual Studio 2008 - Using Rhino Mocks' Expect.Call For A Mock Property In .NET?

Jun 22, 2011

The following C# code works just fine and the test passes as expected.

using NUnit.Framework;
using Rhino.Mocks;
namespace RhinoMocksTesting
{
public interface ITesting

[Code]...

The Expect.Call line produces the following build error: "Overload resolution failed because no accessible 'Expect' accepts this number of arguments." What is the proper way to use Expect.Call with a mocked property in VB.NET? I've seen a couple posts that say Rhino Mocks works better in VB10, but I'm stuck with Visual Studio 2008 for this current project.

View 1 Replies

Concatenating A Variable With A Regex Group Match In Regex.replace?

Apr 5, 2012

I am having an issue where I am using regex.Replace to replace part of a string. The basic idea is that I want to capture the beginning of the string then replace the end of the string with a value from code. For an example pretend I have a string that says "Test Number " followed by number and I want to increment that number. I capture the "Test Number " but when I try to concatenate that capture with the new number it treats the capture ($1) as a literal and replaces the entire string with $1[new number].

[code]...

This will output "We are on Test Number 2", as expected. how I can use a variable in the replacement string portion of the Regex.Replace when including a captured group?

View 1 Replies

Regex: Take Text & Some Special Characters Between The Xml Tags Using Regex On C#.net?

Feb 23, 2012

I want to take the text and some special characters between the xml tags.. My input file contains:

[Code]...

now i want the Regex to take text and the special characters between the tags <line>,<inline>..

View 2 Replies

Increment Regex Match Using Regex.Replace

Jun 21, 2012

I'm creating a program in VB.NET to output multiple images. Some images will have the same file name. If there is multiple files with the same name I want to add "_1_" to the end of the file name. If the "_1_" file already exists I want to increment the 1 to be "_2_". If this file already exists I want to continue incrementing the number ultil it doesn't exist. So for example "filename", filename_1_", "filename_2_", etc. Here is the code that I have tried

[Code]...

View 1 Replies

Regex Builder That Actually BUILDS RegEx From A Highlight

Nov 17, 2011

I've been working straight since yesterday trying to get this to work. I'm a noob to RegEx and I've tested out about 5 different RegEx "builders" but each of them require you to navigate through the options to build the Regex...each of them has failed when I try to use them.Is there an application out there free/paid where you select the line you want to grab and the RegEx is auto generated from that highlight rather than having to try to build the line of code? [code]

View 1 Replies

Cut And Paste The Matching Value?

May 19, 2009

I have a code to read and find match the same value of a text file.This is the code.

Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

[Code]...

View 8 Replies

Matching And Writing?

Sep 17, 2009

I have two files like this

File one
[2 11.63 39.7] X7.705 Y0.735 209.037
Open -209.037
18N694 P321 117461, 50374 100MIL;

[code]...

what i need to do is from file 1 let say my line is like this

[2 11.63 39.7] X7.705 Y0.735 209.037
Open -209.037
18N694 P321 117461, 50374 100MIL;

from the line i must take P321 and match with my File2 if i find the mathing line like this

12N709 11.3611 4.9474 P321 L6 BOTTOM 100MIL 43-CHISEL X11.3611Y4.9474 1922 0

then i must take the value beside P321 which is L6 and write it in my original file like this

[2 11.63 39.7] X7.705 Y0.735 209.037
Open -209.037
18N694 P321 117461, 50374 100MIL; L6

How we can do this. To get the P321 from my file 1 can i use regex pattern like this P*[0-9]. And how to match the regex pattern with file 2 write the content ?

View 1 Replies

Matching Fingerprint In .net?

Oct 23, 2010

How to store fingerprint images in the vb.net and how to match it??"

View 1 Replies

.Net And PHP Rijndael Encryption Not Matching?

Sep 12, 2011

At first i thought it was the padding since mcrypt uses zero padding but i changed the php to use PKCS7 and get the same exact results.I think it has something to do with the padding in the php.Test output from .Net:

Key: d88f92e4fa27f6d45b49446c7fc76976
Text: Testing123
Encrypted: /DMkj7BL9Eu2LMxKhdGT+A==[code]......

View 2 Replies

Code For Pattern Matching?

Apr 22, 2009

I have text like following example

XXZZXXXZXXZXXXXZZZZZZXVVVVVXZVZ

and also I have two patterns like XX and ZZ I want to find longest possible string which include above given two patterns and return starting and finishing index of the array.

View 3 Replies

Combo Box Matching Text?

Nov 29, 2011

In VB6 datacombobox there was a property that you could set that filtered the item list as you typed in the combo box (extended matching I think it was called) so that as the user typed more characters in the box the filtering progressively narrowed down the number of items in the list.The .net control does not seem to have this facility, or does it?Do we have to programatically do it now?

View 7 Replies

Find A Matching Line ?

Aug 19, 2009

Have text file with two parts

[CODE]...

The upper part and the part after the line *+*+* Top *+*+*. What i must do is i must read the value in () at the Top part and compare that value with value in [] from upper part and write it side by side

This is my code so far:

Private Function GetLineMatch(ByRef LineToMatch As String, ByVal LineNumber As Integer, ByVal FileContents() As String) As String

Dim value As String = System.Text.RegularExpressions.Regex.Match(LineToMatch, "([d

[CODE]...

If u see the highlighted value are same. But from top part when it read (2 13.50 26.3)it only matches for one time the value in [2 13.50 26.3] so it take the first line and write and iqnore the second line.

View 3 Replies

Find A Matching Line?

Aug 19, 2009

I have text file with two parts

[code]...

If u see the highlighted value are same. But from top part when it read (2 13.50 26.3)it only matches for one time the value in [2 13.50 26.3] so it take the first line and write and iqnore the second line

View 1 Replies

Finding A Matching And Replacing The Value?

Oct 21, 2009

i have 2 groups of text in my text file

Bottom
11.0 28 Red (2 13.10 04.0) [1 16.71 33.3] 130611 2948 229111 28275
6.5 28 Blue (2 03.00 03.0) [1 05.36 58.3] 132111 -67725 191611 -51225
2.0 28 Blue (1 05.36 45.3) [1 05.36 58.3] 211111 51225 210454 34691

[Code].....

View 14 Replies







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