.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


ADVERTISEMENT

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

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

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

VS 2010 - RegEx Webpage For Date Formatted

Apr 21, 2011

How would I regex a webpage for a date formatted as:
April 21, 2011

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

SQL Exception On Insert Of Dateandtimepicker.value.date Into Date Datatype: (Conversion Failed When Converting Date And/or Time From Character String)

Apr 8, 2010

Title pretty much says it all. How do I format the date of a dateandtimepicker to insert it into the SQL date datatype?

View 20 Replies

Better Way Of Replacing Characters

Mar 8, 2010

I have a code snippet that cleans a string of various characters. [Code]. Is there a better way to do it than this?

View 3 Replies

Replacing Certain Characters?

Apr 20, 2011

While my user is typing text into a textbox i want the characters " to be replaced with ' '. The thing is, when i put ' ' in the replace code, it thinks it is a comment so i cannot run the code without producing an error.Also in my multitext box, everytime i write text and hit ENTER, save and then load it back again, the last line ends with a comma, so:

Line 1
Line 2,

When the text is written to the file i read from, it will show like this:

"Line 1Line 2",

So i need a way of trimming ", when the apostrophe " and the comma , are together. My code already trims "".

View 6 Replies

Ensure That Conversion Of A Date To A String And A String To A Date Will Give The Same Date Format?

Jan 16, 2012

how I can ensure that conversion of a date to a string and a string to a date will give me the same date format.

For example:

Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim d As Date = Date.Now

[code].....

I'm actually only interested in the date part as the label text shows so f is more than I want.But also, the day and month are reversed.

View 10 Replies

C# - Replacing Except For Replace() Function?

Sep 26, 2011

In c programming language,

I can do
printf("%d
", value);

But in c#, how can I do it? For example string is "Good %s everybody"

I want to replace %s with the variable. Are there any solution except str.Replace("%s","good morning");

View 1 Replies

DataGridView Keeps Replacing First Row Instead Of Adding New

Apr 29, 2012

I have a datagridview which gets it's info from a datatable. Everytime I add a new record to the datatable, the datagridview replaces the first record with the new one, instead of adding the new row under the old row.

(Datatable is already declared.)
Private Sub btnWebSave_Click(sender As System.Object, e As System.EventArgs) Handles btnWebSave.Click
'first make sure all text boxes are full of data.
Dim ds As New DataSet
dt = New DataTable
[Code] .....

View 2 Replies

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

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

Getting The Listbox Replacing Item?

May 11, 2012

Items:

1 listbox
2 textboxes (1 textbox input, 1 textbox edit)
4 buttons (1 button add,1 button remove, 1 button edit, 1 button change)

Private Sub add_Click(sender As System.Object, e As System.EventArgs) Handles add.Click
ListBox1.Items.Clear()'clears the listbox1 before puting the input in
ListBox1.Items.Add(textbox1.text)'This adds what's in the textbox1
End sub

[code]....

this workes but if you test this, you will notice that if you edit the selected item and put it back in it's all the way down again and not at the position as it was.For example:

first item: apples
second item:flowers
third item: orange

so if you edit flowers to pears for example then, will appear below orange.i know i know that this is the issue:

ListBox1.Items.Remove(ListBox1.SelectedItem) 'Removes the item first
ListBox1.SelectedItem = ListBox1.Items.Add(TextBox2.Text)' Add the text thats in textbox2

View 2 Replies

Replacing A File Once Opened?

Feb 29, 2012

How can I upload an image 1.png into the program and then once the program is opened, that image gets saved here:LibrariesDocumentsand if there is already a file called 1.png in that directory.

View 5 Replies

Replacing A String In File

Jul 14, 2009

I am using the .Replace function of a string. My string is a module I have added for a resource which looks like this: My.Computer.Network.DownloadFile("This String Will Go Away/details.txt", "details.txt") And then in my application I have:

[Code]...

View 9 Replies

Replacing Characters Using Split?

May 18, 2010

Is it possible to replace string characters using the delimiter and limit of a split function?

For example you have this string "1,1,1,1,1"

I wish to replace sentence number 2 into the string "2" between the "," character so that will be limit number 1.

So the result would be "1,2,1,1,1".

View 4 Replies

Replacing Commas In Csv File?

Mar 24, 2009

I am loading a dataset with a csv file.I remove the quotes around each field in the csv file and I am splitting each field wherever there is a comma:Dim fields() As String = lines(i).Split(","c) The problem is that some of the fields have a comma in the csv file (surrounded by double quotes).How do I replace those commas with a space to avoid problems when loading the dataset?

View 18 Replies

Replacing Data Between Listboxes?

May 21, 2011

im trying to replace data from listbox1.selecteditem to listbox2.selecteditem i have a temp.txt text file that loads in to listbox1 (rlines) this is the methord i use to load each file in to a list box...

Try
Dim file_name As String = tempdata()
Dim stream_reader As New IO.StreamReader(file_name)
Dim line As String

[code]....

it dose what it says and replaces that line of text from the data loading in to listbox2 with the data i selected in listboz1(rlines) but what im looking for is to have the data load in to listbox2 and then have a button so i can select a line in listbox1 and in listbox 2 and it will replace the line from listbox1 in to listbox2 now i can add a line in to listbox2 from listbox1 with

listbox2.iteams.add(listbox1.selecteditem)

but cant find a replace for it

View 14 Replies

Replacing Data In An Array?

Feb 25, 2009

i have data (CSV) that goes into an array. I then update the data but when it updates, it keeps blank elements of the array. Each time i update, the array doesnt replace my old data with the new data, it just seems to create a new element of the array. Then i get the incorrect count of entries.

Reads XML
For Each node As XmlNode In xnames
nvalues = node.InnerXml.Trim
Next

[code].....

View 4 Replies

Replacing Forms Without Closing?

Aug 9, 2009

i have a form (form1 for example) and there is a button ( button1) and too many controls in this form and i have form(form2) and too many controls in this form
i want when i click the button1 i need every control in form1 to disappear and instead i want form2 and it is contents to be loaded in the form1

OR

the second form is showing without the user noticing that there's too forms
(replacing)

can i do this and if i can't , can i create a custom control/controls to do this
and if i can how can i do this?

View 6 Replies







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