.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


ADVERTISEMENT

RegEx - How To Retrieve String Variable From External Source And Parse It

Dec 7, 2011

Part of my project is to retrieve a string variable from an external source (google docs) and parse it. This string represents width and height. I have no problem retrieving, I just need to parse it in to two strings. The string has 4 variations.

Here are examples:
3"x4"
3"hx4"w
3hx4w
3x4

The width is always the first number and the height is always the second. Sometimes, the width and height have decimal points. Any way to parse this into two strings of the numeric values only?

View 3 Replies

Way To Parse A Math Operator Off Of A String Of Numbers?

Dec 7, 2010

Given a string as a form of input (parsed from an input file) which represents a number and a mathematical operator (<, >, <=, >=, !, !=, and a few others), what is a really fastefficient way to chop off that operator, compare it to a list of valid operators, and then set an "operator" variable to a state (i.e., Enum) representing the identified operator, then return just the number (as a string)?I'm open to various ideas and implementations.I've tried several (about 6-7) myself, and find I'm not really satisfied with the speedThe fastest so far is a For Each loop that walks my list of "valid operators", and compares that operator's string representation against the chopped off bit from the numeric string. I determine the amount to chop off by the length of each valid operator in the valid list.

Here's a code example of the fastest implementation. Assume input like <378 and a valid ops list of <, >, !, or >=79 and a valid ops list of <=, >=:
Friend Function FindMatchingOp(ByVal Haystack As String,

[code].....

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

Parse Numeric Values In String Form Into Real Numbers?

Sep 14, 2009

I have a string I want to parse. I could write the code to do so, but I figured that VS.NET has a parser that should do this for me.however, I can't find it. All the searches I do return info on how to parse numeric values in string form into real numbers. It would be nice if the MSDN search had some ways to allow users to enter more details than just search text and 3 ways to filter out irrelevant stuff. In any case, I also tried things like string.parse (nope - although I kinda figured this would be it.) I also looked at Enum.parse, but the code indicates that it works with arrasy of items, not strings.

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

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

Regex To Parse HTML Tables

Dec 19, 2010

I am trying to remove the tables within an HTML file, specifically, for the following document, I'd like to remove anything within the tags <TABLE....> and </TABLE>. The document contains multiple tables with texts in between.

The expression that I came up with, <TABLE.*>s*[s|S]*</TABLE>s*, however would remove the text in between the tables. In fact it would remove everything between the first <TABLE> and the last </TABLE> tags. I would like to keep the texts in between and only remove the tables.

[Code]....

View 2 Replies

VS 2008 RegEx : How To Parse This File

Apr 7, 2009

I'm messing around with regular expressions and I can't seem to figure out how to parse this file.It's basically a lua file containing a table like:

TableName = {
["QuotedString"] = {
["QuotedString"] = {

[code]....

Some things with the file are standard, like the "TableName" (Never in quotes) starts the table. Variables always have [" "] around them and then equal something like ["Test"] = 0. However, the variable could have multiple variables within it. split up the file within each {} and then try to parse each ["QuotedString-Key"] = 0?

View 28 Replies

.Net Regex To Parse Specific JSON Format

Feb 20, 2010

I'm writing a little web service which generates SO/SF/SU/MSO user flair in the form of an image with various "themes". I find this preferable to using the HTML/JS solutions offered by SO as it's more flexible and also works better in forum signatures.

I'm retrieving the data using the apparently unofficial API (More info here). I can have the data in HTML or JSON. I assumed the JSON would be easier to parse.

Unfortunately, I'm not great at regexes. and the best I can come up with is some very hacky sub-stringing. I believe a regex should be the most elegant solution

regex that matches ID, GravatarURL, ProfileURL, DisplayName, Reputation and Badge Counts (Bronze/Silver/Gold).

FWIW This is to be used in a VB.Net project (in case that affects the syntax at all)

[Code].....

In case any of you are interested, some screenshots of the flair as a work in progress are available here: Me, Jeff Atwood, Joel Spolsky

View 2 Replies

RegEx - Parse CSV File And Replace Certain Characters

Sep 2, 2010

I've used regular expressions in the past. I have an app that parses a .csv file and replaces certain characters (commas). Here's an example..
item1, item2, item3, fruits are apples, oranges, grapes. Squash is a vegetable, not a fruit.
What my app does is search each line between character1 and character18 and replace all "," with "~". How this is done through regular expressions?

View 2 Replies

C# - Parse Using Regex Class Of System.Text.RegularExpressions

Mar 4, 2011

I have a string which i need to parse using Regex class of System.Text.RegularExpressions. I need to find if the first 2 characters of the string are either "00" or "07" or "16" or "23".

View 1 Replies

C# - Using .NET Regex To Parse WSUS Updates For Currently Installed Packages?

Apr 5, 2012

Problem: Current regex pattern does not filter all lines. Adding ^ to the beginning and $ to the ending of the pattern seems to break it as well. If I try it ont gives partial results using options(multiline & case insensitive). Using it in the application returns nothing at all.

View 1 Replies

RegEx To Parse Valid Paths From A Text File?

Sep 27, 2011

I'm attempting to parse a text file containing several Windows paths; I'd like to use regular expressions if possible, and I'm using VB.NET.The file is formatted somewhat like so:

M - Network Mode
C:ClientSystem - System Path
C:ClientProducts - Product Path

[code].....

View 2 Replies

Regex - Regular Expression To Parse Whitespace-delimited Data?

Jun 18, 2009

I have written code to pull some data into a data table and do some data re-formatting. I need some help splitting some text into appropriate columns.

CASE 1

I have data formated like this that I need to split into 2 columns.

[Code]...

column is the first 11 characters That is easy.column 2 should contain all the text after the first 11 characters up to but not including the first number.The last column is all the text after column 2

View 4 Replies

VS 2008 Regex - Parse Out Some Links Via Search And Fill A Text Box With Said Results

Mar 25, 2009

What I'm trying to do is parse out some links via a google search and fill a text box with said results. This is the code I have in a module which I call upon inside of a command button.

Imports System.Text
Imports System.Text.RegularExpressions

Module Module1

[CODE]...

View 8 Replies

Asp.net - Parse Data/numbers From Table Cells C#?

Dec 10, 2011

I have a string which contains html code from a webpage. There's a table in the code I'm interested in. I want to parse the numbers present in the table cells and put them in textboxes, each number in its own textbox. Here's the table:

<table class="tblSkills">
<tr>
<th class="th_first">Strength</th><td class="align_center">15</td>
<th>Passing</th><td class="align_center">17</td>

[code]....

As you can see there are 14 numbers. To make things worse numbers like 19 and 20 are replaced by images and numbers lower than 6 have a span class.

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

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

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

Asp.net - Decimal.parse Fails For Currency String Created With String.Format?

Apr 5, 2011

I have a field that I display via: String.Format({0:c},amount) This produces the string "$28.28" However, when I try to convert back to a decimal amount, I get an incorrect format exception: amount = Decimal.Parse(amount.Text, NumberStyles.Currency) I also tried it with NumberStyles.AllowCurrencySymbol with the same results. I verified that the value in amount.Text is "$28.28". Am I missing something? Shouldn't these two operations use the same currency symbol and formats?

View 2 Replies

Parse Excel Formula "=a(b,c,d)" With Regex?

Dec 23, 2010

I am trying to parse the parameters of Excel formulas like "=a(b)", "=a(b,c)", "=a(b,c,d)". I'd like extract the function name "a" and the parameters "b", "c" and "d".

There are loads of examples on SO to parse HTML and so forth, but none specifically for parentheses.

So far, I've got this "=(.+)(([^,)]*)(,[^,)]*)*)" but when I parse "=a(b,c,d)" it puts "a" in match(1), "b" in match(2) and ",d" in match(3). So "c" is lost and the comma before the "d" is a pain.

How can I parse a string like this with an arbitrary number of parameters, ideally dropping the commas?

The ability to parse "=a(b(c),d(e(f)))" would be great...

Edit: I know that a parser is the correct solution and I have used Devin Cook's excellent Gold Parser with great results before.

However, the particular case I'm facing is to extract the arguments from a known Excel formula. Specifically, if the formula contains the string "=Travel(", I know that it will have 4 arguments and if they don't parse it's not a problem. This is simply a "nice to have" function which can fail occasionally without it being an issue.

regex for "=a(b,c,d)", "=a(b,c,d,e)", etc., with the constraint that there will be no nested parentheses or commas?

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







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