Regex - Get The Numbers Surrounded A Character ?

Oct 27, 2011

I'm creating a calculator, and I need a way to get the numbers surrounded a character I provide.

For example:
Equation: 5+5*2/7
Character: *
Result: array(5, 2)

I was wondering if regex would be able to do this and if it can.

View 8 Replies


ADVERTISEMENT

Sql - .net Regex Character Syntax?

Feb 18, 2011

I can't get my sql query using regex to work in vb.net. If I write

Dim localConnection As New MySqlConnection = ConnectionNew(DBName)
Dim da as MysqlDataAdapter
Dim ds as new DataSet
Dim rows as long

[code]....

It returns null, even though there is a cell containing "ABC". When I run it directly on the database, it returns the row correctly.If I remove the [A-Z], it works fine in both circumstances.

View 1 Replies

Regex / Check For Preceding And Following Character

Jun 10, 2011

Sometimes when backing up an sql file using phpmyadmin (database stuff), for some reason it forgets to double up a single quote, resulting in an error when loading the sql file back into the database when required. A line in such an sql file looks like this;[code]As shown in the example, phpmyadmin did double up the quote in "you're" as it should, but it forgot to double up the one after "27", resulting in an error.As you can see it's like this (*value*, *'value'*, (and so on) but beforehand I can;

A) Never know how many values are in such a string
B) Can't simply split the values by "," because the value itself can hold a comma aswel.

It would be easy if every value was like this; *'value'* because then I could split by " ', ' " but that's not the case, and I also never know what location the values not enclosed in single quotes are. I also can't simply double up all single quotes in the entire string because then it will also double up the ones that are enclosing the values, resulting in an error during upload again.So yeah, what I need to get done is single out all the values with regex ($1, $2 etc.) and then string.replace single quotes in those values but *only* if said single quote is not preceeded or followed by another single quote, else it would become a tripple quote resulting in an error again.

View 1 Replies

Use Regex To Identify Only One Contained Character?

May 9, 2012

I have a form like this

And its code :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text.Contains(" ") Then

[Code].....

Now what code should I use when I click the button, if TextBox1 contains 2 SPACE characters, it will split into 3 parts, but if it contains only one SPACE, it'll split into 2 parts ?

View 5 Replies

C# - Using Regex To Match Any Character Until A Substring Is Reached?

Jul 18, 2011

I'd like to be able to match a specific sequence of characters, starting with a particular substring and ending with a particular substring. My positive lookahead regex works if there is only one instance to match on a line, but not if there should be multiple matches on a line. I understand this is because (.+) captures up everything until the last positive lookahead expression is found. It'd be nice if it would capture everything until the first expression is found.

Here is my regex attempt:

@@FOO[(.*)(?=~~)~~(.*)(?=]@@)]@@

Sample input:

@@FOO[abc~~hi]@@ @@FOO[def~~hey]@@

Desired output: 2 matches, with 2 matching groups each (abc, hi) and (def, hey).

Actual output: 1 match with 2 groups (abc~~hi]@@ @@FOO[def, hey)

Is there a way to get the desired output?

View 3 Replies

Make A Regex That Can Detect A Certain Character String

Dec 1, 2010

How do I make a regex that can detect a certain character string that is either all by its self in a line, or separated by white space.

If I have the line:

"ot"

Or the line

"sdf gdfg dv ewrsef fvdf ot sdfsd sdot"

I want to be able to detect the 'ot', except for the one that is 'sdot'

View 5 Replies

Regex To Find A Word That Includes An Escaped Character?

Jul 17, 2009

I am using a simple regular expression (in C#) to find a whole word within a block of text.

The word may appear at the beginning, end or in the middle of a the text or sentence with in the text.

The expression I have been using word has been working fine however if the word included a special character (that has been escaped) it no longer works. The boundary is essential so that we do not pick up words such as vb.net as a match for .net.[code]...

View 3 Replies

VS 2010 RegEx - Split On Comma Character, Excluding Those In Quotationmarks?

Aug 9, 2011

Given an input string like the following:I, Need, Some, Coffee, Before, I, "Fall, Asleep" I need to split this into parts like so:

I
Need
Some

[code]...

Splitting on the comma character alone is easy enough, but how can I handle the quotationmarks? Regular expressions is not on my strong side, and I have been googling for quite a bit without any good results.

View 14 Replies

.net - Regex Test For NUMBERS?

Feb 28, 2009

I have found a Regex that test if the text passed to a TextBox is an email.

If Regex.IsMatch(email.Text, "^(?("")("".+?""@)|(([0-9a-zA-Z]((.(?!.))|[-!#$%&'*+/=?^`{}|~w])*)(?<=[0-9a-zA-Z])@))" + "(?([)([(d{1,3}.){3}d{1,3}])|(([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,6}))$") _

[code]....

View 4 Replies

Regex On Get Only First Few Numbers From Left To Right?

Aug 15, 2011

I am pretty new on regular expressions, but as far as I've been wandering around Google, the only thing I could do to solve my problem is through regex. I have a collection of strings which have patterns like these:

"3 - Orange, Lemon"
"4 - Pineapple, Orange"
"12 - Lime, Strawberry"

[Code]...

Only the first few numbers. A comment, suggestion, or point to the right links/articles would help because so far I couldn't manage to find a decent tutorials that easy to understand.

View 3 Replies

Regex - Regular Expression Needed To Replace Return Character With Another String?

Jul 20, 2009

I'm trying to replace all the carriage return characters in a string obtained from a multi line text box in a Windows Form with the string ", <BR>" so that when I use the string in some HTML it displays correctly.

Function Blah(ByVal strInput As String) As String
Dim rexCR As Object
rexCR = CreateObject("VBScript.RegExp")

[code]....

View 5 Replies

Regex Email Address Validation Fails If Underscore Character Present

Aug 31, 2010

My Regex works, except if the email address entered has an underscore character (_) in it.

Because of my lack of experience with regular expressions, I'm not sure where in my pattern I'm supposed to add the offending character to allow it:

Dim pattern As String = "^[-a-zAZ0-9][-.a-zA-Z0-9]*@[-.a-zA-Z0-0]+(.[-.a-zA-Z0-0+)*." & _
"(com|edu|info|gov|int|mil|net|org|biz|name|museum|coop|aero|pro|tv|[a-zA-Z]{2})$"

He said he fixed it by adding the _ after the numeric check.

I see the A-Z0-9, but I'm not sure which is the numeric check...

View 2 Replies

.net - Parse Numbers From String Using Regex In .NET?

Feb 16, 2010

I am trying to parse the digits to store in a variable from a string in VB.NET (would like to also include the decimal point).

Here is an example string: Refund issued for $27.74

View 2 Replies

RegEx - How To Gather All Numbers In String

Sep 4, 2009

I am trying to gather all numbers in this string which is the name of an image file. The name of the string is ABC09072009XYZ777000111.jpg. When I use
Dim rx as new Regex("d")
Console.Writeline(rx.match(input))
It only returns the first set of numbers before the xyz. I need them all.

View 3 Replies

Game Programming :: Make The Program Know When A Black Stone Is Surrounded?

Oct 23, 2009

I'm not positive if this should be here or in graphics so I'm sorry if I'm posting it in the wrong section.I'm trying to make a program for the game Go. Now before getting upset that I want to make the game go I just want to say that I have looked for months for this specific thing and I still have yet to find it. I want to make something to simulate go so that two people can play on the same computer. The problem I ran into was capturing stones. Stones are captured when surrounded and then they are taken from the board. The problem is that I don't know how to make the program know when a black stone is surrounded.

I have thought of a grid detecting but the possibilites on a 19x19 area are too high for anybody to sit down and program. I have also thought of using picture boxes and the edges to detect other pictures, but there are ways for stones to group together and the opponent must surround all stones to capture them.

View 3 Replies

Regex - Import Phone Numbers From A String?

Jan 25, 2010

I am trying to wirte a function for a Phone number class called "import phone number". It should take any string with 10 digits in it somewhere (and allow for an extension), and import them into it's own properties: AreaCode, Prefix, Suffix, and Extension (aaa-ppp-ssss-xxxx...).

I check the input with a regex to make sure it's valid, now i want to tokenize those pieces into their respective properties. What I have looks like this (incomplete):

Public Sub ImportPhoneNumber(ByVal anyNumber As String)
'phone number is 10-digits long, e.g.: 012-345-6789
Dim reg_exp_10 As New Regex("^((D*)d(D*)){9}((D*)d){1}(((x|ext){1}(d)+)?|D*)$", RegexOptions.IgnoreCase)

[Code].....

View 1 Replies

RegEx - International/Domestic Phone Numbers?

Mar 25, 2009

(^(+[1-9][0-9]*(([0-9]*)/-[0-9]*-))?[0]?[1-9][0-9-]*)/(^([0-9]( /-)?)?((?[0-9]{3})?/[0-9]{3})( /-)?([0-9]{3}( /-)?[0-9]{4}/[a-zA-Z0-9]{7}))$I'm trying to write a RegEx to check for International and Domestic phone numbers. This appears to be working for domestic phone numbers but it doesn't look to work for international numbers. Is there something I'm missing? Can anyone else try this with numbers you know and just let me know if it's missing anything?

View 1 Replies

RegEx 20 Real Numbers Separated With Commas?

Mar 11, 2010

I worked around to modifying regular expression below but i could't get what I need. I google it, many things found but not for what i want. Dim valid AS Boolean = Regex.IsMatch(TextBox1.Text, "^(,?d+){0,20}$")Allow numbers exactly like 32,1,6,32,12,21,21,54,675,8,4,3,2,9,0,21,21,21,43,744 in TextBox1. Perfect.

View 4 Replies

Form A Regex To Get The Numbers From A Giving String With Certain Conditions?

Nov 1, 2011

I have a string like this

(THQ836721='Yes' and BRQ836716='Yes') or (BRQ836717='Yes') and (THQ836728='Yes' and BRQ836756='Yes') or (BRQ836117='Yes') and (SYSQ123='No')

I need a Reg Ex to get the numbers after THQ,BRQ and SYSQMy string may smaller or shorter or may have any times of this THQ,BRQ or SYSQ.form a Reg eXpression to get the numbers .The length of numbers may vary I am using VB.Net in VS2008?

View 1 Replies

Regex - Separating Text From Numbers Using Regular Expressions?

Nov 7, 2010

I'm having trouble parsing some text. Here's an example of the text:

201 BBQ 0.000 9.000 0.099 0.891 9.000 0.000 0.000 0.000
705 W 1 PC 0.000 135.000 0.295 39.825 0.000 0.000 135.000 0.000
2106 ONL 9.99 41.141 3.000 4.110 12.330 3.000 0.000 0.000 29.970

Here's the latest incarnation of the code I've been trying:

objInfo = System.Text.RegularExpressions.Regex.Split(
newLine,"(d{3,5})|([0-9]+[.]+[0-9]+)|(w*)")

I'm having trouble because I'm avoiding getting many blank spaces in the array after splitting. I'm trying to avoid using the optional | character but I get no results when I set it up without it!

I've spent much of the evening reviewing regular expressions and I've downloaded the following programs:

RegEx Designer.NET
Antix RegEx Tester
Expresso

I'm having trouble because the description contains a decimal point SOMETIMES and sometimes it doesn't. The description sometimes contains a whole number sometimes it doesn't.My friend recommended I use awk to divide it into columns. The thing is...I teach a Community Education class with Visual Basic .Net and I need to improve my RegEx skills.

View 1 Replies

Regex - Textbox That Accepts All The Characters But Returns Only Numbers

Aug 1, 2011

I need the code to filter the data entered in a textbox. Although it accepts all the characters during runtime, the code should remove all the strings and alpha numeric characters except the numbers (which would be my output). I tried the following code but guess it won't do:

a = Textbox1.text
Dim value As Decimal = CDec(Regex.Replace(a, "[D]", ""))

View 3 Replies

Transferring Only Numbers After A Specific Character

May 21, 2009

I'm trying to transfer only the numbers after the £ Character from Textbox1 into Textbox2. If textbox1 contains numbers before the £ character then it just transfers the first numbers before the £ character which is not required.[code]

View 5 Replies

Regex To Match 4 Groups Of Letters/numbers, Separated By Hyphens?

Jul 14, 2011

I need a regular expression that will match this pattern (case doesn't matter):066B-E77B-CE41-4279

View 4 Replies

Regular Expression (RegEx) To Replace Floating-point Numbers In XML?

Aug 22, 2011

I'm using Visual Basic 2010 Express to edit an XML file. I want to replace items that have (typically) non-zero floating point numbers with a single zero.

View 4 Replies

VS 2010 : Use Regex To Check If The User Add The Numbers Of Phone In This 'Formula'?

May 3, 2012

I need to use regex to check if the user add the numbers of phone in this 'Formula'

0911111111,0922222222,0933333333
must the number start with '09'
must the number contains '10' characters'
must the numbers seperated by Comaa ','

View 4 Replies

VS 2008 Remove All Character Except Numbers And Decimals?

Sep 5, 2009

I want to know if there is an easy and short way to remove all characters except for numbers and decimals from a string. Either that or have a textbox that will only except numbers and decimals, but not a masked textbox.

View 2 Replies

Regex - Regular Expression To Extract Numbers From Long String Containing Lots Of Punctuation?

Aug 27, 2009

I am trying to separate numbers from a string which includes %,/,etc for eg (%2459348?:, or :2434545/%). How can I separate it, in VB.net

View 4 Replies

VS 2005 Read User Input Using Textbox But It Only Can Read Character And Numbers?

Jan 2, 2010

I know how to read user input using textbox but it only can read character and numbers. Is it possible that I want to read user input equation?

Example:

User type A+B
User put range of A and B.
1.25<A< 3.56
2.45<B< 9.87

I failed to read the equation using textbox. Is it there are other ways that can use to read equation input A+B?I am using VS2005 and VB.Net. I really new in this programming using VB.Net.

View 3 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







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