Parsing Out The Contents Within Brackets Using Regex?

Dec 20, 2011

I'm sure this is simple and I'll probably be embarrassed to have this question in my profile but I can't seem to get this Regex correct.

I'm tring to extract just the digits from the last group of the following string:

Properties[1].Securitymeasures[14].AdditionalSecurityType

so I want to have a regex that will return 14

The Regex I have come up with is:

[(d)+]

However - the match is returning "[14]" - including the brackets and I do not understand why. I have surrounded the d with parenthesis which should mean that this is the data I want to capture.

View 2 Replies


ADVERTISEMENT

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

C# - .Net String Parsing Library Or Regex For Parsing .Net Code Files

Mar 5, 2009

I would like to be able to parse vb.net code files, so I can examine the collection of Subs, Functions (and their contents, including comments), private variables, etc. I can be open the actual source code files. So for example, if I have:

[Code]....

View 7 Replies

Ignore Curly Brackets In Regex Expression

Nov 14, 2011

I am trying to build an application which does the following :

1) write some text in a richtextbox

2) when user clicks a button, the app will replace the text with another text in {} braces.

what I want is that the next time, the regex searches for any text it should exclude those which are present in {}. for eg : my world is good world and a happy world and will be a better world for everyone. first pass - change word "world"

[Code]....

View 1 Replies

Regex - Extract Text From Within First Curly Brackets?

Jan 31, 2012

I have strings that look like this {/CSDC} CHOC SHELL DIP COLOR {17}

I need to extract the value in the first swirly brackets. In the above example it would be

/CSDC So far i have this code which is not working

[Code]...

View 3 Replies

Regex - Get/split Text Inside Brackets/parentheses

Apr 25, 2012

Just have a list of words, such as:

gram (g)
kilogram (kg)
pound (lb)

just wondering how I would get the words within the brackets for example get the "g" in "gram (g)" and dim it as a new string. Possibly using regex?

View 3 Replies

VS 2008 Regex Match Strings Between Only When Outside Of Complete Brackets

Jul 14, 2009

I am trying to make a regex that will match strings between a comma only if the comma is outside of complete brackets. Brackets inside of " " should not count. Examples below. [code]

View 6 Replies

C# - Remove Square Brackets And Single Quotes Regex Not Working

May 9, 2011

I have the following string [custID] = 'A99999999' I am trying the following to remove the square brackets and the single quotes Regex.Replace(sql, "/[[]']+/g", " ") but that's not working. I keep getting the same results Note: sql is a variable holding the string above. I want the result to be

View 5 Replies

.net - Global RegEx Replace Function To Create HTML From Square Brackets?

Nov 30, 2011

I have some existing code that looks something like this:

[tag:cb cbid="12345" cbwidth="200" cbclassname="calloutbox" cbposition="left"] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
[tag:cb cbid="123" cbwidth="200" cbclass="calloutbox2" cbposition="left"] Suspendisse eleifend enim a magna pretium porttitor.

I need to write a VB .Net global function that will match these [tag:cb] and take the optional parameters and rewrite the string with Html tags.

<div id="12345" width="200" class="calloutbox" position="left">content (based on id)</div>

View 1 Replies

Regex - Parsing File For Pattern RH 09/27/08 11:49 11:49:00.024

Mar 1, 2010

Trying to parse a text file for records starting with an RH space and a date. I need to return the entire line. I expect to find about 6000 in the file. Example of a full record:

RH 09/27/08 11:49 11:49:00.224 COA292 H393 2664FB753 178 -54.82 8.98 C 431 264 13 040 34 24.45-074 58 57.93 H Snipit of text file:

[Code]...

View 2 Replies

VS 2008 Parsing Html Using Regex

Apr 3, 2011

i need help parsing html using regex..i am hardly find the exact expression to use.

[Code]...

View 2 Replies

.net - Parsing Fixed Length File With Regex?

May 8, 2012

I'm parsing fixed length file with .NET 3.5 and Regex. This file is from bank. In customer name sometimes there is one characters from this set &,(),[],',"". These are characters, so far I've encountered. There can be anything else. Because of this my regex is failing. My regex is [A-Za-z0-9s-.,'""""(){}[]]{35}. Is there any wild card I can use for special chars rather than specifying individually. I also tried . but didn't work.

View 2 Replies

Parsing Or Regex On HTML In A Text File?

Jun 26, 2009

I just spent about 2 hours searching this forum on this topic but I need some advice. I am looking to extract certain data from HTML source code that I have down loaded into a text file its about 9KB in size.I am looking to keep all email address found. How would this work or what would be the best method to use? This is what I would like to extract and write to another file:

[Code]...

View 20 Replies

Regex - Parsing Excel Reference With Regular Expression?

Oct 14, 2010

Excel returns a reference of the form

=Sheet1!R14C1R22C71junk

("junk" won't normally be there, but I want to be sure that there's no extraneous text.)I would like to 'split' this into a VB array, where

a(0)="Sheet1"
a(1)="14"
a(2)="1"

[code]....

I'm sure it can be done easily with a regular expression, but I just can't get the hang of it.

View 2 Replies

VS 2008 Parsing "1.8.1.0" Out Of Html - Regex .NET

Mar 17, 2012

VB
<dd itemprop="softwareVersion">1.8.1.0</dd>

1.8.1.0 is not the same all the time, It changes and it could be 2.01.01 , 3.2 , 5 , 1.21 etc

Is there anyone who can make a regex for it ?

View 2 Replies

Parsing String Each Iteration, Or Parsing Once And Storing?

Mar 16, 2011

I'm creating a vb.net winforms application that will take in user given strings, parse them, and print out labels with variable information. The given string will be used in all the labels, but the variable part of the string will change with each label.

My question is: is it better to parse the strings one time, then store those values in arrays, or to parse the string each time a label is printed? Which will perform better? Which is better practice? What is the proper way to test something like this?

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

Get Each Value Between Brackets?

Nov 4, 2009

So since no one seemed to know the resolution to my last thread, which I will let die now.[code]...

View 3 Replies

Asp.net - VB Brackets In Enum?

Mar 24, 2011

I'm finding this in some legacy code and just curious what the brackets are for?

Public Enum myEnum
none = 0
abc = 2

[code]....

View 1 Replies

Get The Al Information From The Brackets Of Each Sin()?

Jan 30, 2012

i wrote a code to get all information with in brackets of each sin() ,which i would like to give as my input to text box. but i am not able to get it exactly, for example i write "sin(90*2)+sin(60)+sin(60+(75*2))+sin(50)+sin(20)" in textbox i need "90*2,60,60+(75*2),50,20" as my out put here is my code what i wrote,

[Code]...

View 9 Replies

Get The All Information From The Brackets Of Each Sin()?

Feb 15, 2012

i wrote a code to get all information with in brackets of each sin() ,which i would like to give as my input to text box. but i am not able to get it exactly, for example i write "sin(90*2)+sin(60)+sin(60+(75*2))+sin(50)+sin(20)" in textbox i need "90*2,60,60+(75*2),50,20" as my out put here is my code what i wrote,

public class form1
Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button25.Click

[Code].....

View 3 Replies

How To Get The Al Information From The Brackets Of Each Sin()

Jan 30, 2012

i wrote a code to get all information with in brackets of each sin() ,which i would like to give as my input to text box.but i am not able to get it exactly, for example i write "sin(90*2)+sin(60)+sin(60+(75*2))+sin(50)+sin(20)" in textbox i need "90*2,60,60+(75*2),50,20" as my out put here is my code what i wrote

[Code]...

View 2 Replies

VB Brackets In Enum?

Apr 22, 2009

I'm finding this in some legacy code and just curious what the brackets are for?

Public Enum myEnum
none = 0
abc = 2

[code].....

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

Copy Contents Of One Array Of Booleans To Another, Preserving Contents But Adding Additional Boolean Values?

Nov 11, 2010

i have an array of booleans whose current boolean values I want to preserve but add additional length to the array? How can I achieve that? My code looks like this:

Dim Array() As Boolean
Dim ArrayInterimShort() As Boolean
ReDim Array(119)

[code]....

View 9 Replies

Difference In Using Brackets Around NameSpace

Oct 28, 2010

What is the difference in usage of brackets around namespace? such as:
[Assembly].Load("assemblyname")
Assembly.Load("assemblyname")
What makes the brackets special?
I know the usage of the brackets in variable declaration... meaning allow usage of reserve keyword.

View 1 Replies

Have The Tournament Brackets In The Program?

Feb 27, 2009

I am writing this Visual Basic GUI for a competition. I want to have the tournament brackets in the program but I'm facing a lot of troubles. It looks likes it requires intensive amount of work especially that there are 35 teams competing.

View 6 Replies

How To Get All Information From Brackets Of Sin Function

Jan 26, 2012

What I need is I what to get all information within the parenthesis of Sin(). For example, I have created one one textbox in my user interface. I wanted users to enter some trigonometric expresiions like " sin(90+(25+25))". For that I want all the information present with in the parenthesis of sin().

Public Class Form1
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
Dim i As Integer = 0
Dim j As Integer = 0
Dim x As Integer = TextBox1.Text.IndexOf("sin", i)
[Code] .....

I tried above code to get the string within the parenthesis of sin() but I am not able to get the answer.

View 12 Replies







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