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


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

Replacing Two Variables In A Query String?

Dec 20, 2010

I am wondering how to replace two variables in a query from selections that the user makes. One variable is chosen by a combo box called cboYEARMONTH and the other is selected from a list view called employeeListView. I know that I can use .replace to insert the YearMonth into the string but, how do I also replace the EmployeeID in the query string?

[Code]...

View 2 Replies

Regex - How To Remove Double Spaces In .net

Feb 29, 2012

It's the same with how to remove double white space using regexp

View 3 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 - Remove Non Alphanumeric Characters Except Spaces

Apr 27, 2012

I have to process a string that could include all sorts of non-standard characters and I've been asked to provide a regular expression that will match and remove all characters that are non-alphanumeric except punctuation and spaces. Is there a way to do this?

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

File I/O And Registry :: Reading A HTML File And Replacing Certain Parts?

Nov 5, 2010

friend of mine has no HTML knowledge so I'm attempting to write a program that replaces certain parts of a html file to suit his needs.I've edited the HTML file and marked certain parts with "tags" like this:

#IMAGEURL1# I have a textbox where he can copy + paste an image URL and hopefully the #IMAGEURL1# is replaced with the contents of the textbox.

So can someone please enlighten me to-as how to open a HTML file (there's no textbox to display the contents just yet, I'll add one if needed), find the specified text and then replace it with whats in a textbox.

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

Set String To Blank Spaces Before Reading String From File?

Mar 26, 2011

I've always been slightly stumped as to why the following happens if I write[code]...

View 4 Replies

Finding/replacing Multiple Sets Of String Within A Parent String?

Mar 28, 2012

I've got an issue with a program I am writing. The specific issue is replacing characters in a parent string by finding, and matching, specific characters within it that are parsed from an external xml file. It's for a chat-like client.Here's the 2 classes I am using to pull the emote strings, titles, and id from external XML:

Imports System.Text.RegularExpressions
Imports System.Xml.Serialization
Public Class emote

[code].....

View 1 Replies

Create A String From Parts Of A Different?

Jan 28, 2010

This string is automatically generated with an application I can't access or change[code]....

View 1 Replies

Extracting Parts Of A String?

Sep 28, 2009

Many types of credit cards have the same format. This format is XXXX-XXXX-XXXX-XXXX, where X is a digit.The dashes are embedded into the string containing the card number.Create a console application to * Declare String variables Partl, Part2, Part3, Part4, and InputString. * Read a credit number consisting of 16 digits only, no hyphens, into InputString.* Write the statement(s) to extract each four-digit segment into Partl, Part2, Part3, and Part4* Display the four parts.This is what I have, and I cannot figure out what I'm doing wrong because there is an error when it runs.

Sub Main()
Dim inputString As String = "1234567891234567"
Dim part1, part2, part3, part4 As String

[code]....

View 3 Replies

Extracting Certain Parts Of A Text From A String

May 12, 2011

what is the command line to single out certain parts of text from a string only..for example string = "Hellodullardtomboy".what is the command to capture only the word "DULL" between "hello" and "ardtomboy" only.

View 5 Replies

Get Parts Of A String That Constantly Changes Size And Value?

May 2, 2012

I have a stream reader that reads a website text and places it in a txt file synonyms.txt
then I can read to a specific line in the textfile that the results always end up on and place that line in a richtextbox in my project.the line looks something like this:

\tab\tab\tab\tab <br /><div class="ResultsSubTitle">Synonyms (Grouped by Similarity of Meaning) of <span class="Accent I">verb</span> house</div><br /><div class="Accent Sense">Sense 1:</div>house<br /><span class="equals">accommodate, hold, admit</span><br

[code].....

View 2 Replies

VS 2005 Delete All Parts Of String?

Nov 15, 2010

I am trying to delete all parts of string after first occurence of '(' in the string Thought I had it earlier it but I didnt test it properly

HTML
Dim Str As String = TextBox1.Text
Dim words() As String = Str.Split(New [Char]() {"("c}, System.StringSplitOptions.None)
Dim lastWord As String = words(words.Length - 2)
Does not work when I have two occurences of '(' in string

View 2 Replies

[2008] How To Trim 2 Parts Of A String

Mar 4, 2009

I currently have a string

<TEXT default_lang="en" str="Button text"/>

and I wish to remove parts of the string, I want to remove

<TEXT default_lang="en" str="
from the beginning and from the end:
"/>

so I am just left with Button Text in a text box

View 8 Replies

Put Some Spaces In String In .Net?

Sep 8, 2010

i have string like

Dim Test as String = "abc " & " def"

what above code does is gives is "abc def" as output, what i want is "abc--------def" (where hash sign is spaces i need) i have tried

Dim Test as String = "abc----" & "----def"

for some reason (dot)net only takes it as one single space. check above(1) example ,i gave two spaces but it got converted to one space.

Dim Test as String = "abc" & Char(9) & "def"

doesn't work (found char(9) solution on internet)

Dim Test as String = "abc" & space(8) & "def"

doesn't work I have tried another 10 different option but none seems to be working for me.

View 16 Replies

Finding Spaces In A String

Feb 14, 2009

I want to be able to find both spaces using the indexof method. Here's my code so far. Basically the program will turn the string "Will Smith" to "Smith, Will" But I noticed when I type in a name with a middle initial or middle name "Will J Smith" I would get "J Smith, Will" And I want to be able to find that second space when its there and apply a code that would produce "Smith, Will J" When there is a second space. How would I go about doing so?

[Code]...

View 2 Replies

Insert Spaces Into A String?

Nov 12, 2009

Is there a way to take an integer, say 10, and convert that to 10 spaces? What I've got is a text field that the users enters a number. I then need to convert that number into spaces and insert those spaces into a string of text. I've found several places to convert text to an integer but not the other way around.

View 5 Replies

Remove Right Most Spaces From A String?

May 12, 2011

lets say I had a string variable that contained "Hello World!", (or whatever the string contained) how would i remove the the right most spaces to make it say "Hello World" (im reading in items from a text file using substrings that has fixed positions with one line of the text containing several different items) or does it automatically eliminate the right most spaces???

View 6 Replies

Remove Spaces From A String

Oct 29, 2009

How do you remove spaces from a string in VB.NET?

View 3 Replies

Removing All Spaces In A String?

Nov 8, 2010

Is there any function in vb.net that removes all spaces in a string. I mean a string like ' What is this' should be 'Whatisthis'

View 3 Replies

Take Spaces In A String Using SubString?

Jan 18, 2010

Dim strValue as String=""
Dim strOutputValue as String=""
strValue ="One"
strOutputValue = "One+(7 Spaces here) "

strValue is changing dynamically that is fixed 10 characters. but i need Out is

MsgBox("Total characters " &strOutputValue.Length)

View 3 Replies

Break Up String With Spaces Or Next Line

Feb 5, 2009

If i have a string "mystring" and it holds something like

"aaaaaaaa bbbbbb fffffff qwrt afsa hghf"

how can i get each word into its own string "mynewstrings()"? the number of spaces between the words isnt always the same either.

View 13 Replies

How To Add Spaces To Numeric String Every 2 Numbers

Oct 21, 2011

I used a regular expression, which handles both numbers and letters in strings of arbitrary length, in one line of code.
dim rtn as String = Regex.Replace(input, "..", "$& ")

I'd like to take numeric strings of arbitrary length and insert a space every 2 characters.
So 1233456 becomes 12 33 45 6. Is there a way I can use format as string or IFormatProvider, like? That would put a limit on how long the string could be though, right? Since I'm casting to a long.

CLng((input)).ToString("## ")
I'd like to take strings of arbitrary length and insert a space every 2 characters.
123dssas4rr should become 12 3d ss as 4r r

View 4 Replies

How To Replace Spaces With Underbars In A String

Nov 2, 2011

I have a string that I need to place to a file, but when I do place it to file, it gets cut off at the space, and the words after the space are placed to a new line. So I decided to place an underbar in place of all spaces, to avoid that problem. So how can I search the string for spaces and replace each with an underbar?

View 2 Replies







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