VB RegEx - Extracting And Replacing Paths?

Dec 23, 2011

I have file paths such as:

' Any number of folders before and after the Project name
C:acdProject1efgsomefile.someextension'

[code].....

View 1 Replies


ADVERTISEMENT

Extracting And Replacing Paths?

Aug 19, 2010

I have file paths such as:

' Any number of folders before and after the Project name
C:acdProject1efgsomefile.someextension'

How would I:Extract only the path before the project name?

C:acd
Extract the path after the project name?
efgsomefile.someextension

Note: Of course given the filename.Would Split be better or some complicated regex?

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

.net - Replacing The Regex Date?

Nov 16, 2011

I have dates like the following (note trailing 'T')

2011-11-07T15:24:28
2011-11-07T

With regex i need to extract just the date part so both will look like this

20111107
20111107

.net Have a webservice that is returning a date like 2011-11-07T15:24:28, but on some occasions it returns date with no time but still with the trailing T. This causes .net's cdate function to bail out.

View 3 Replies

Replacing For Each Stringbuilder With A Regex?

Jul 29, 2009

I have a sub that takes a string, replaces all characters that are not alphanumberic and or a "/" and replaces it with a space. Then it goes through and replaces all multiple spaces with a single space.

Right now I am using a string builder to do this. My problem is that this action must be done several hundred to thousand times depending on the filesize I am comparing it to (1 richtextbox line = 1 string)

I believe I should see a significant increase in performance if I can figure out how to do this using a single regex.replace function.How would I go about constructing a regex.replace function that would keep all alphanumberic characters and "/" and replace everything else with a single space?

[Code]...

View 6 Replies

Replacing Text With Regex?

Jan 2, 2010

I have 2 questions regarding replacing certain text in a string which has been found using regular expressions.For example this is my string:"<span style="font-weight: bold">This</span> is <span style="font-weight: bold">2010</span>"

View 4 Replies

RegEx, Finding And Replacing A Certain Substring?

Jan 27, 2009

I've got a string which could or could not contain the substring "/announce". I would like to replace this part of the string with "/scrape" if its found...so far nothing tricky. But heres the thing: I only want to replace it if the '/' in it is the last occurring in the string. Heres what I mean:

Heres a scenario where I want the replace to happen:

MyStringWithRandomText/announce?x=19
would become:
MyStringWithRandomText/scrape?x=19

And heres another scenario where the '/' in announce is not the last '/' occuring in the string, so I dont want to replace it:

MyStringWithRandomText/announce/foo?x=19

I hope that made sense. Not sure if there is a way to handle this by only using RegEx

View 2 Replies

Use RegEx In Extracting Data In A File?

Apr 13, 2009

I've tried to extract certain data using Regex in a File. but it seems not working.No errors and warnings have been found.[code]...

View 2 Replies

Asp.net Mvc - Regex For Extracting Second Level Domain From FQDN?

Nov 21, 2009

I need to extract the second level domain from a FQDN. For example, all of these need to return "[url]....

Here's what I have so far:

Dim host = Request.Headers("Host")
Dim pattern As String = "(?<hostname>(w+)).(?<domainname>(w+.w+))"
Dim theMatch = Regex.Match(host, pattern)
ViewData("Message") = "Domain is: " + theMatch.Groups("domainname").ToString

It fails for example.com:8080 and bar.foo.example.com:8080.

View 3 Replies

Regex - Regular Expressions - Extracting Wildcard Value

Jul 15, 2011

I need help extracting the value of a wildcard from a Regular Expressions match. For example:

[Code]...

View 2 Replies

RegEx Query - Replacing Spaces Within Parts Of A String?

Oct 24, 2011

I have a program that goes through SQL statements, identifying component parts with a space. eg: -

SELECT * FROM tblSales WHERE CustomerID=10 AND Year=2011

Would produce the following as separate components: -
"SELECT","*","FROM","tblSales","WHERE","CustomerID=10","AND" and "Year=2011"
The problem I have however is the use of spaces within values eg.:-
SELECT * FROM tblSales WHERE CustomerNameID='Test Company' AND Year=2011
Using the same space-separating logic, this would produce components of:

[Code]...

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

.net - Regex Replacing Non-words Chars In Strings, Ignoring Specific Chars?

Oct 8, 2011

In VB.net I've got the following line that removes all non-alphanumeric chars from a string:

return Regex.Replace(build, "[W]", "")

I now need to extend this to remove non-alphanumeric chars that aren't [] or _. I've changed the line to:

return Regex.Replace(build, "[W[]_]", "")

However I'm pretty sure that this says

replace non-word or [ or ] or _

how do I negate the tests for the [] and _ chars so that it says

replace non-word and not [ and not ] and not _

Some examples:

"[Foo Bar_123456]" => "[FooBar_123456]"
"[Foo Bar_123-456*]" => "[FooBar_123456]"

View 2 Replies

Regex - Extracting HTTP Link(http://) For The String In .NET?

Sep 28, 2011

I have the following column values in my table Sample values:

[URL]

I want to have 2 variables having the links and content separate - example:

[URL]

I guess it can be done via String functions or regular expression.

View 2 Replies

Visual Basic 2008 Extracting Div Tags, Extracting Title Tags, Extracting Keyword Tags, Parsing Div Tags?

Nov 7, 2009

I was just wondering how to extract or parse any particual tags (whichever I specify) from webpages. I know how to extract text and links from webpages, but I tried to use the same method from the following code for div tags, title tags etcetera and it doesn't seem to work:

[Code]...

View 2 Replies

Extracting Url Source Code ,url Not Extracting All?

Apr 25, 2012

I have been working lately on a program who extracts URl Source codes!The program does work with most of URL but not for MEdiafire URL!When i check the source code from the web browser i can see there is some code missing;y tried diferrent types of Encoding.

Example:This is the final source code extracted from WEBBROWSER(Firefox,InternetExplorer,GoogleCrome)

--------------------------------------------------------------------------------------------
<div class="mf_lightbox_btns lb-footer" style="text-align: right;">
<a href="javascript:void(0);" class="secondary btn" onclick="$('body').removeClass('has-virus'); return false;">Dismiss Message</a>
<a href="http:www.bitdefender.com/mediafire/fix-it.html" target="_blank" class="alt btn">Get BitDefender</a>

[code]....

View 1 Replies

Vb 2008 : Drag And Drop Replacing Text In Txt1 With Txt2 And Replacing Txt2 With Txt1 At Same Time?

May 18, 2011

txt1 = help and txt2 = me! txt3 = not here, when i enter the other box i want the okay to drop sign to come up, after drop txt1=me! and txt2 = help.if i drag to txt3 display the can't drop sign.Iv'e tried everything all i can do is replace one way.also,i want the can't drop and can drop simbols to show.so far

Public
Class Form1
Private
Sub tbMouseDown(ByVal

[code]....

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

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

No Value On All Code Paths

Aug 26, 2009

In more and more of my functions (althought they still work) i'm getting a warning the function doesn't return a value on all code paths.[code]...

View 3 Replies

Reference Paths On Win XP And 2K?

Jan 14, 2010

My development machine runs Windows XP, but the target machine runs Windows 2000 with .NET 2.0.I've set my compile options to compile 2.0, which is fine.However, I have some references which are causing issues.For example, Microsoft.Office.Interop.Outlook.dll - in VS2008 the path is shows as the C:Windowsassembly folder which works fine. Until the app is built and run on the target machine and fails:Could not load file or assembly 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture-neutrl, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.Presumably because on Windows 2000 the assembly folder is C:WINNT.I cannot work out how to target the WINNT folder for my references.

View 9 Replies

Add File Paths To A CheckedListBox?

Feb 4, 2011

The end result I am looking for is I want to add File Paths to a CheckedListBox. I only want certain file extensions and if a file by the same name but a specific extension exsists allready then I do not want to add those files to the CheckedListBox.

Example: I am only wanting these filetypes in my CheckedListBox (.gif, .tif, .bmp, and .jpg).However if the filetype (.PNG) allready exsists with the same filename (i.e. image. png and image.jpg) I then do NOT want to add that JPG. Only files that do not allready have a PNG with the same name. (I hope I was able to make this clear)

My current code will add the filetypes (.gif, .tif, .bmp and .jpg) to the CheckedListBox. However I do not know how to have the code only add the files that don't have the PNG.Here is my current code:[code].....

View 2 Replies

App That Basically Gets Paths To Servers

Oct 12, 2007

I designed an app that basically gets paths to servers I have admin rights to, I am doing such things such as checking available space on the servers etc., the problem I am having is my app only works if I manually login via something like (start, run, \server) and supply my admin username and password just to store that authentication.How do I code this so it prompts the user in my program ONE time for all 5 servers (they all use the same username and password)

View 5 Replies

Can't Return A Value On All Code Paths

Mar 5, 2010

I'm attempting to use the Left function to extract the 3 leftmost characters from a string.

I declare the function as follows

Public Shadows Function Left(ByVal str As String, ByVal Length As Integer) As String

End Function

I get a notification that "function Left doesn't return a value on all code paths"

View 3 Replies

Detect If Two Paths Specify The Same Folder?

Feb 21, 2011


[code].....

View 12 Replies

Detect Installed Paths?

Nov 13, 2010

but i can't complete it if i dont know how to make it auto detecting the pathsexample: i have a combobox and only the text COD 4 MWand i have a textbox so when they select COD 4 MW in the combobox the install path shows in the textbox.

View 1 Replies

How To Navigate Registry Via Paths

Jan 4, 2012

I've been trying to wrap my head around using the registry, but I have to say I'm a little lost. Is there a way I can use a "path structure" to write to a specific key, rather than using it as a dim and storing it in memory?

[Code]...

View 2 Replies

Paths To External Resources?

Feb 16, 2009

I am preparing a project for distribution, and I need advice as to how to establish my paths to some of the dynamic data elements; sound clips, external imagery and a database.I am reading the environment.startuppath, but it's pointing all the way in to the debug folder, whixh I'm sure I'm not going to be using when I publish things for distribution.I was hoping for something that could establish a relative base folder, and then just reference a few subfolders from there.

View 14 Replies







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